Yes, this topic is old. But maybe this can help some new people.
In Windows, i have success creating shortcuts to files and folders using this code:
{In the Unit1 , we need to use Windows and ShlObj. This is not portable to Linux.
uses
Windows, Classes, SysUtils, FileUtil, Forms, Controls, Graphics,
Dialogs, StdCtrls, ShlObj, ActiveX, ComObj, ExtCtrls,
ExtDlgs, Buttons, UnitGlobales; //maybe some of this units are not necessary
}
//Create a Windows shortcut to the calculator pressing the button Button1
Procedure TForm1.Button1
Var
IObject : IUnknown;
ISLink : IShellLink;
IPFile : IPersistFile;
PIDL : PItemIDList;
InFolder : array[0..MAX_PATH] of Char;
TargetName : String;
LinkName : WideString;
Begin
TargetName :='C:\WINDOWS\System32\calc.exe'; //use complete path to desired target
//Calc.exe is in other path in Windows 98, check.
IObject := CreateComObject(CLSID_ShellLink) ;
ISLink := IObject as IShellLink;
IPFile := IObject as IPersistFile;
with ISLink do
begin
SetPath(pChar(TargetName)) ;
SetWorkingDirectory(pChar(ExtractFilePath(TargetName))) ;
end;
// if we want to place a link on the Desktop , this function
//returns the path of the desktop of the current user in Win XP
SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, PIDL) ;
SHGetPathFromIDList(PIDL, InFolder) ;
//Of course, we can create the link in other path.
LinkName := InFolder + '\My Calculator Link.lnk' ;//Absolute path and name of the new .lnk file
//The user only sees "My Calculator Link" as the label of the shortcut.
IPFile.Save(PWChar(LinkName), false) ; //here the new link is created: a new file
//named "My Calculator Link.lnk" is created in the user's desktop directory.
End;
Hope this helps someone.