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('SoftwareMicrosoftWindowsCurrentVersionRun' + 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('SoftwareMicrosoftWindowsCurrentVersionRun', sProgTitle);
reg.Free;
end;
Add Or Remove Startup Items in Delphi
These two short methods will allow you to easily add or remove program startup entries to the system registry to auto load applications when Windows loads.