Hi, Alistair,
 
Thank you for your reply.
I added  "Registry,ShlObj,OLE2,ComObj" to uses clause, but the first line  
MyObject := CreateComObject(CLSID_ShellLink);
comes error of incompatible types IUnknown when I compile that.
What units do I have to add to uses clause?
 
Jim
-----Original Message-----
From: Alistair George <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Date: Sunday, 20 December 1998 23:17
Subject: Re: [DUG]: Windows shortcut creating

Yep, this is the code I use to insert my program into the Startup folder - modify filename Prorem to suit and if not startup folder change those other parameters around:
procedure TPRForm.SetStart;
var
MyObject: IUnknown;
MySLink: IShellLink;
MyPFile: IPersistFile;
FileName: string;
Directory: string;
WFileName: WideString;
MyReg: TRegIniFile;
begin
MyObject := CreateComObject(CLSID_ShellLink);
MySLink := MyObject as IShellLink;
MyPFile := MyObject as IPersistFile;
FileName := application.Exename;
with MySLink do begin
SetArguments('');
SetPath(PChar(FileName));
SetWorkingDirectory(PChar(ExtractFilePath(FileName)));
end;
MyReg := TRegIniFile.Create(
'Software\MicroSoft\Windows\CurrentVersion\Explorer');
// Use the next line of code to put the shortcut on your desktop
Directory := MyReg.ReadString('Shell Folders', 'Startup', '');
WFileName := Directory + '\ProRem.lnk';
MyPFile.Save(PWChar(WFileName), False);
MyReg.Free;
end;

Reply via email to