Hello,

Does anyone know how to create a shortcut in the Windows Start Menu?

Tia,
Slash0r
Posted on 2004-04-29 02:26:58 by Slash0r
Create it in the folder "C:\Documents and Settings\All Users\Start Menu\Programs" or something like that.
Posted on 2004-04-29 07:26:39 by roticv
Here's a little lib I wrote for making shortcuts:

MakeDesktopLink   PROTO   :DWORD,:DWORD,:DWORD

MakeLink PROTO :DWORD,:DWORD,:DWORD
ResolveLink PROTO :DWORD,:DWORD

MakeLink:
Creates a shortcut (LNK) file
Parameters:
lpLinkTarget = Pointer to the fully qualified path of the link target
lpOutputFile = Pointer to a link path\name at which to create the link
lpDescription = A description to add to the link
This function uses the first icon in the file as the link icon
lpOutputFile must have the extension .LNK
CoInitialize must be called at some point in your program before this function
Returns S_OK if successful

MakeDesktopLink
This is a wrapper function for MakeLink that creates a link on the desktop
It works the same as MakeLink except that the path is not supplied with lpLinkName
Parameters:
lpLinkTarget = Pointer to the fully qualified path of the link target
lpLinkName = Pointer to a name for the link file
lpDescription = A description to add to the link, can be NULL
The first icon in the file is used for the link icon
The extension .LNK is added to lpLinkName automatically
If lpDescription is NULL, no description will be added
The desktop folder is found through it's PIDL in order to work with Windows 95
CoInitialize must be called at some point in your program before this function
Returns S_OK if successful

ResolveLink:
Resolves a shortcut returning the path of the target file
Parameters:
lpbuffer = Buffer in which the path is returned
lpLinkPath = Fully qualified path to the LNK file
The lpbuffer and lpLinkPath can point to the same buffer, in which case the
Link target will be copied over the link file buffer.
CoInitialize must be called at some point in your program before this function
Returns S_OK if successful


To find the start menu use the MakeDesktopLink proc as a template with:

invoke SHGetSpecialFolderLocation, NULL, CSIDL_COMMON_STARTMENU, addr PIDL

invoke SHGetPathFromIDList, [PIDL], addr szStartmenupath
Posted on 2004-04-29 10:45:24 by donkey
Perhaps this thread should be included in the FAQ... :)
Posted on 2004-04-30 17:20:07 by QvasiModo
Donkey: thanks!

QvasiModo: I think it's a good idea to include it in the faq. It isn't well documented anywhere.
Posted on 2004-05-01 04:10:11 by Slash0r
No probs Slash0r,

Made a mistake on the CLSID for programs, it's CSIDL_COMMON_PROGRAMS (17). Just replace the desktop CLSID in MakeDesktopLink with the one for the programs folder and it should be OK.
Posted on 2004-05-01 05:55:39 by donkey
I agree. This thead has been moved.

Regards,
:NaN:
Posted on 2004-05-12 09:12:47 by NaN