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
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Cheng Wei
Sent: Wednesday, 18 October 2000 8:26 a.m.
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Re : Copying Files

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 

Reply via email to