Hi all. I have found some code which works fine with NT etc but I would like to
be able to reverse the process eg by unchecking, remove the startup item.
There is no method for IPersistfile to delete. Any hints on how to use
persistfile below to delete the existing key? Thanks, Al+
procedure TFastShellLink.Execute;
var
ShellObject: IUnknown;
ShellLink: IShellLink;
PersistFile: IPersistFile;
FileName: WideString;
Reg: TRegistry;
RegStr: String;
i: Integer;
begin
// Geting folders location from Registry first
Reg := TRegistry.Create;
with Reg do
try
RootKey := HKEY_CURRENT_USER;
OpenKey('\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders',
True);
case FCreateIn.FShellFolder of
sfDesktop: RegStr := 'Desktop';
sfStartMenu: RegStr := 'Start Menu';
sfProgramsMenu: RegStr := 'Programs';
sfStartup: RegStr := 'Startup';
sfMyDocuments: RegStr := 'Personal';
end;
RegStr := ReadString(RegStr) + FCreateIn.FSubfolder;
except
end;
Reg.Free;
// and creating the path for ShellLink (if needed)
if FCreateIn.FCreatePath then
for i := 1 to Length(RegStr) do
if RegStr[i] = '\' then
CreateDir(Copy(RegStr, 1, i));
// then creating Shell link
ShellObject := CreateComObject(CLSID_ShellLink);
ShellLink := ShellObject as IShellLink;
PersistFile := ShellObject as IPersistFile;
with ShellLink do
begin
SetArguments(PChar(FParamString));
SetPath(PChar(FLinkTarget));
SetWorkingDirectory(PChar(WorkingDirectory));
case FRunAs of
raMaximized: i := sw_ShowMaximized;
raMinimized: i := sw_ShowMinNoActive;
else i := sw_ShowNormal;
end;
end;
// and finally saving the link
FileName := RegStr + '\' + FLinkName + '.lnk';
PersistFile.Save(PWChar(FileName), False);
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/