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;
>> Change this
to
S: String;
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(sDirPath));
SHGetSpecialFolderLocation(0,CSIDL_DESKTOP,PIDL);
SHGetPathFromIDList(PIDL,ShortCutDirectory);
{ Error here -------------------
>> Now this will work - you cannot append to an
array, but you can to a string;
S := ShortCutDirectory;
ShortCutFileName := S +
'\';
{--->
ShortCutFileName := ShortCutDirectory + '\' + { produces
an"Incompatible types" error}
{ If I comment out the " + '\' " code then the
"Incompatibe types" error is fixed but the
following part of the line produces an
error "not enough actual parameters", (which
may be caused by the missing "\" of course) }
ChangeFileExt(ExtractFileName(sEXEName)),'lnk';
-------------------------------}
tmpPFile.Save(pWChar(ShortcutFileName),
FALSE;
end;
The program will not compile as shown for the
line marked {--->