function CreateShellLink(mPath: string; mWorkingDirectory: string;
mFileName: WideString): Boolean;
var
vShellLink: IShellLink;
vPersistFile: IPersistFile;
vUnKnown: IUnKnown;
begin
Result := True;
try
vUnKnown := CreateComObject(CLSID_ShellLink);
vShellLink := vUnKnown as IShellLink;
vPersistFile := vUnKnown as IPersistFile;
vShellLink.SetPath(PChar(mPath));
vShellLink.SetWorkingDirectory(PChar(mWorkingDirectory));
vPersistFile.Save(PWChar(mFileName), False);
except
Result := False;
end;
end; { CreateShellLink }
procedure TForm1.Button1Click(Sender: TObject);
begin
CreateShellLink(ParamStr(0), ExtractFilePath(ParamStr(0)),
GetSpecialFolderDir(CSIDL_DESKTOPDIRECTORY) + '/' +
ChangeFileExt(ExtractFileName(ParamStr(0)), '.lnk'));
end;