码迷,mamicode.com
首页 > Windows程序 > 详细

delphi让exe开机自启动

时间:2015-10-17 19:11:51      阅读:567      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!