How to Add or Remove Startup Items in DelphiTwo methods for Delphi which allow you to add or remove Startup Items in Delphi providing means for your application to run on startup.
These methods will allow you to easily add or remove startup entries to the system registry to auto-load applications when Windows loads.
pascal
procedure RunOnStartup(sProgTitle, sCmdLine: string; bRunOnce: boolean );
var
sKey : string;
reg : TRegIniFile;
begin
if( bRunOnce )then
sKey := 'Once'
else
sKey := '';
reg := TRegIniFile.Create( '' );
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.WriteString('\Software\Microsoft\Windows\CurrentVersion\Run' + sKey + #0, sProgTitle, sCmdLine );
reg.Free;
end;
procedure RemoveOnStartup(sProgTitle: string);
var
sKey : string;
reg : TRegIniFile;
begin
reg := TRegIniFile.Create( '' );
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.DeleteKey('\Software\Microsoft\Windows\CurrentVersion\Run', sProgTitle);
reg.Free;
end;