Run Program on Windows startup
Hello,
I've been using the code below to have a program automatically start up with Windows.
It works fine with XP and as far as I know earlier Window's versions.
However, it won't work with Vista and the message...
Failed to set Data appears.
with this in the ondestroy event
Has anyone cured this problem?
Blod
I've been using the code below to have a program automatically start up with Windows.
It works fine with XP and as far as I know earlier Window's versions.
However, it won't work with Vista and the message...
Failed to set Data appears.
- Code: Select all
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;
with this in the ondestroy event
- Code: Select all
if checkbox1.checked then
RunOnStartup('Myprog','C:\folder\Myprog.exe',
Has anyone cured this problem?
Blod