Make sure you test
this on a early version of Win95. It has caused me problems in the
past (error messages saying can't find xxx.dll, application refuses to
load).
Guy
Brown
TimeMaster
Systems
procedure TForm1.CreateShortcutOnDesktop(const sExeName: String);
// sExeName should include full path
var
tmpObject :
IUnknown;
tmpSLink :
IShellLink;
tmpPFile :
IPersistFile;
PIDL :
PItemIDList; ShortcutDirectory: array[0..255] of
Char; ShortcutFilename :
WideString; begin {
Create a COM object, initialise to ShellLink interface
} tmpObject :=
CreateComObject(CLSID_ShellLink); tmpSLink := tmpObject as
IShellLink; tmpPFile := tmpObject as
IPersistFile;
{ Create shortcut icon on the
Desktop
} tmpSLink.SetPath(pChar(sExeName));
tmpSLink.SetWorkingDirectory(pChar('')); // replace '' with your working
directory string SHGetSpecialFolderLocation(0,
CSIDL_DESKTOP, PIDL); SHGetPathFromIDList(PIDL,
ShortcutDirectory); ShortcutFilename := ShortcutDirectory + '\' +
ChangeFileExt(ExtractFileName(sExeName), '.lnk');
tmpPFile.Save(pWChar(ShortcutFilename), FALSE);
end;
regards
Chen[Guy
Brown] g
|