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
Cheng
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Colin R Dillicar
Sent: Wednesday, 18 October 2000 19:04
To: Multiple recipients of list delphi
Subject: [DUG]: Re : Copying Files

Hi all,

 
Thanks for help with my query yesterday re above. 
 
1. Added FMXUtils to users clause
2  Copied the FMXUtils DCU into my work directory.
3. Typecast the 'ToFile' string to PChar
 
All fixed now. 
 
Now all I need to do having copied the files off the diskette into two directories (Run, and associated Database) is to generate a shortcut using the program's Icon and place it on the desktop.
 
Pointers to method please.
 
Thanks

   Colin


Reply via email to