Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Run your application on Startup programatically
2 comments. Current rating: (2 votes). Leave comments and/ or rate it.
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; | |  | |  |
Comments:
|
anonymous
|
 |
|
|
What the hell does that mean? English, PLEEEESE!!!!
|
2008-04-16, 16:41:35 (updated: 2008-04-16, 16:42:03) |
vampwitch
|
 |
|
|
You forgot to add 'Registry' in the uses clause ;)
|
|