wauger
asked on
Create a Desktop Shortcut for an program in C
Hello All. Is it possible to write a C program to create a desktop shortcut for a specific static executable? I am trying to package some software for end users and want to have a program automatically create a shortcut on the desktop for the program that just installed in the package.
Thanks a lot.
Thanks a lot.
See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/Shell/programmersguide/shell_int/shell_int_programming/shortcuts/shortcut.asp ("Shell Links") - this article comes with sample code.
BTW, there's more sample code available - check http://www.microsoft.com/msj/defaulttop.asp?page=/msj/archive/s2bd.htm ("Fusing Your Applications to the System Through the Windows95 Shell")
ASKER
Thanks. But I really dont want to use the Windows Shell environment if possible. Is there another way? Cant I just write a plan C program and compile a small executable to create a desktop shortcut? Thanks agian.
>>Cant I just write a plan C program and compile a small executable to create a desktop shortcut?
That is what I am suggesting. However, this C program will have to use the shell's API do achieve that.
That is what I am suggesting. However, this C program will have to use the shell's API do achieve that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That is perfect. Thanks a lot. But I tried compiling the C code and got multiple errors. Any ideas? Thanks
>>Any ideas?
Yes. Post the errors - I forgot to clean my crystal ball :o)
Yes. Post the errors - I forgot to clean my crystal ball :o)
ASKER
Oh, yea. That would help. Here you go....
shortcut.c: In function `main':
shortcut.c:23: parse error before `*'
shortcut.c:30: `hres' undeclared (first use in this function)
shortcut.c:30: (Each undeclared identifier is reported only once
shortcut.c:30: for each function it appears in.)
shortcut.c:31: `psl' undeclared (first use in this function)
shortcut.c:31: incompatible type for argument 1 of `CoCreateInstance'
shortcut.c:31: incompatible type for argument 4 of `CoCreateInstance'
shortcut.c:48: structure has no member named `Load'
shortcut.c:61: `szGotPath' undeclared (first use in this function)
shortcut.c:64: `wfd' undeclared (first use in this function)
shortcut.c:75: structure has no member named `Release'
shortcut.c: In function `main':
shortcut.c:23: parse error before `*'
shortcut.c:30: `hres' undeclared (first use in this function)
shortcut.c:30: (Each undeclared identifier is reported only once
shortcut.c:30: for each function it appears in.)
shortcut.c:31: `psl' undeclared (first use in this function)
shortcut.c:31: incompatible type for argument 1 of `CoCreateInstance'
shortcut.c:31: incompatible type for argument 4 of `CoCreateInstance'
shortcut.c:48: structure has no member named `Load'
shortcut.c:61: `szGotPath' undeclared (first use in this function)
shortcut.c:64: `wfd' undeclared (first use in this function)
shortcut.c:75: structure has no member named `Release'
That is weird - did you use the code from the link or copy the code from my above comment?
ASKER
oh, i just copied it from your comment. I should try the link first.
er, could you not just make a shortuct to it to distribute, then open that with your program and change where it points to?? Its a binary file but the path part is in text, it should be an easy, quick way to do this.
not a great way to do things, but that way you don't need os specific headers or anything, if its still giving you trouble and you need a fix now it may help...
not a great way to do things, but that way you don't need os specific headers or anything, if its still giving you trouble and you need a fix now it may help...
No comment has been added lately.
To cleanup this TA, I will recommend to moderators that this question is:
*** Answered by: jkr ***
Please leave any comments here within the next seven days, or finalize the question if you own it
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
peterchen
EE Cleanup Volunteer
To cleanup this TA, I will recommend to moderators that this question is:
*** Answered by: jkr ***
Please leave any comments here within the next seven days, or finalize the question if you own it
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
peterchen
EE Cleanup Volunteer
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept jkr's comment as answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Kent (Kdo)
EE Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
Accept jkr's comment as answer
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
Kent (Kdo)
EE Cleanup Volunteer