Hi folks,
I am led to believe that the following code should
allow me to create a Desktop icon and shortcut to a program I have dreated and
placed in a directory somewhere.
procedure TForm1.CreateShortCutOnDesktop(var
sExeName,sDirPath
:string);
{ Parameters :- sExeName = Program name and sDirPath = Directory Path } var tmpObject :
Unknown;
tmpSLink : ShellLink; tmpPFile : PersistFile; 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.SetPath.SetWorkingDirectory(pChar(sDirPath)); { Error - "Not enough actual parameters} {--->}
SHGetSpecialFolderLocation(0,CSIDL_DESKTOP.PIDL);
{ Error - Record, object or class type required} {--->} SHGetPathFromIDList(PIDL.ShortCutDirectory); { Error - Undeclared Identifier :
'ShortCutDirectory'}
ShortCutFileName := ShortCutDirectory + '\' + ChangeFileExt(ExtractFileName(sEXEName)),'lnk'; tmpPFile.Save(pWChart(ShortcutFileName), FALSE; end; The program will not compile as shown by errors
sussessively generated by commenting them out, for the lines marked
{--->}
I would appreciate some assistance in de-bugging
these.
Thanks in advance. Colin
|
- RE: [DUG]: Creating a Desktop shortcut to a program Colin Dillicar