怎么才能让程序自启动?(100分)

  • 主题发起人 主题发起人 shake
  • 开始时间 开始时间
S

shake

Unregistered / Unconfirmed
GUEST, unregistred user!
我想做个程序运行一遍后就能在每次
windows运行时自启动,听说要写注册表,
试了一下没成功,那位大侠告知?如何实现
最好给一下代码。
 
写到这里吧:
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run
 
procedure Tsetup.Checkbox3Click(Sender: TObject);
begin
if Checkbox3.checked then
begin
with TRegistry.Create do
try
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey('Software/Microsoft/Windows/CurrentVersion/run', false) then
WriteString('Autowall',Application.ExeName);//
end;
finally
CloseKey;
free;
end;
end else
begin
with TRegistry.Create do
try
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey('Software/Microsoft/Windows/CurrentVersion/run', false) then
DeleteValue('Autowall');
end;
finally
CloseKey;
free;
end;
end;
end;
 
procedure tform1.oncreate(Sender: TObject);
begin
with TRegistry.Create do
try
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey('Software/Microsoft/Windows/CurrentVersion/run', false) then
WriteString('Autorun1',Application.ExeName);//
end;
finally
CloseKey;
free;
end;
end else
begin
with TRegistry.Create do
try
begin
RootKey:=HKEY_LOCAL_MACHINE;
if OpenKey('Software/Microsoft/Windows/CurrentVersion/run', false) then
DeleteValue('Autowall');
messagebox(handle,'error','write regist error!'mb_ok);
end;
finally
CloseKey;
free;
end;
end;
 
有一个ABF Software可以很方便的达到这一点(带例程).
你可以到Sohu用"ABF 控件"搜一下就可以找到.
 
多人接受答案了。
 
后退
顶部