Creating shortcuts on the desktop, start menu, send to menu, or quicklaunch toolbar
Here's how to create a shortcut on the desktop, start and programs menu, send to menu, quick launch toolbar, startup, favorites and documents folders. Simple usage is like this: CreateShortcut('c:\winnt\system32\notepad.exe', _DESKTOP); to create a shortcut of Notepad.exe on the desktop.
uses Registry, ShlObj, ActiveX, ComObj;
type ShortcutType = (_DESKTOP, _QUICKLAUNCH, _SENDTO, _STARTMENU,
_DOCS, _STARTMENUINI, _STARTMENUPROGS, _FAVORITES);
procedureCreateShortcut(FileName: string; Location: ShortcutType); { proc to create a shortcut on the desktop or startmenu. } var
MyObject : IUnknown;
MySLink : IShellLink;
MyPFile : IPersistFile;
Directory,
LinkName : string;
WFileName : WideString;
MyReg,
QuickLaunchReg : TRegIniFile;
begin
MyObject := CreateComObject(CLSID_ShellLink);
MySLink := MyObject as IShellLink;
MyPFile := MyObject as IPersistFile;