WIN32 / How to Create a Desktop Icon?

BlitzMax Forums/BlitzMax Programming/WIN32 / How to Create a Desktop Icon?

Scaremonger(Posted 2015) [#1]
Hi,

All the examples I've looked at on the Web use COM to create a desktop shortcut. Does anyone know of any other way to do this?

Cheers,
Si...


PhotonTom(Posted 2015) [#2]
This is the best I could find: http://superuser.com/questions/392061/how-to-make-a-shortcut-from-cmd


Scaremonger(Posted 2015) [#3]
Thanks @PhotonTom

So far I have cobbled together the following:

Shortcuts.bmx
SNIP - See below for bug-fixed version


shortcut.c
SNIP - See below for bug-fixed version


It creates the shortcut in the current directory but doesn't let me create the file in a folder. If I put a full path in the filename it doesn't do anything.

Strangely, if I comment out the graphics() command it doesn't work!


Chalky(Posted 2015) [#4]
You could always use your current code to create the shortcut then "move" it into the required folder using RenameFile().


Scaremonger(Posted 2015) [#5]
Cheers @Chalky, After adding CoInitialize() / CoUninitialise() to the call it seems to work okay now.

I've added support for icons etc and this now seems to be working fine. Let me know if you find anything wrong or that can be improved.

Use Bruceys bah.volumes module to get the users desktop.

CreateShortcut.bmx

TShortcut.bmx

shortcut.c