首页 > Windows开发 > 详细

delphi让exe开机自启动

时间:2015-10-17 19:11:35      阅读:325      评论:0      收藏:0      [点我收藏+]

procedure AutoRunOnSystemStart(Title, FileName: String);
const
  _Software_Microsoft_Windows_CurrentVersion_Run_ : string = ‘\Software\Microsoft\Windows\CurrentVersion\Run\‘;
var
  Reg: TRegistry;
  Key: String;
begin
  Reg := TRegistry.Create;                // 创建一个新的注册表
  Reg.RootKey := HKEY_LOCAL_MACHINE;      // 将根键设置为HKEY_LOCAL_MACHINE
  Key := _Software_Microsoft_Windows_CurrentVersion_Run_; // 键Run
  Reg.OpenKey(Key, True);                 // 打开这个键
  Reg.WriteString(Title, FileName);       // 在Reg这个键中写入数据名称和数据值
  Reg.CloseKey;
  Reg.Free;
end;

AutoRunOnSystemStart(self.Name, paramstr(0));           // 开机自启动

paramstr(0);为当前目录下exe名,delphi7下可用Application.ExeName

delphi让exe开机自启动

原文:http://www.cnblogs.com/studypanp/p/4887954.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!