Sometimes you may need to have an application run once (or every time) on Windows
startup time. The following code contains the function OnStartup which shows to do this
with the means of the operating system.
Use OnStartup e.g. like this:
OnStartup('any title does not matter', 'c:\temp\runthis.exe', true);to run your application "runthis.exe" exactly one time.
Procedure OnStartup (const PgmTitle, CmdLine: String; RunOnce: boolean);
Var
Key : String;
Reg : TRegIniFile;
Begin
If RunOnce Then
Key := 'Once' #0
Else
Key := #0;
Reg := TRegIniFile.create ('');
Reg.RootKey := HKEY_LOCAL_MACHINE;
Reg.WriteString ('Software\Microsoft\Windows\CurrentVersion\Run' + Key,
ProgTitle, CmdLine);
Reg.Free
End;