delphi 将程序加裁到启动项  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi 将程序加裁到启动项


 //加裁启动项
procedure SetAutorun(aProgTitle,aCmdLine: string; aRunOnce: boolean );
var
hKey: string;
hReg: TRegIniFile;
begin
if aRunOnce then
//程序只自动运行一次
hKey := 'Once'
else
hKey := '';

hReg := TRegIniFile.Create('');
//TregIniFile类的对象需要创建
hReg.RootKey := HKEY_LOCAL_MACHINE;
//设置根键
hReg.WriteString('Software\Microsoft\Windows\CurrentVersion\Run'
+ hKey + #0,
aProgTitle,
//程序名称,可以为自定义值
aCmdLine );
//命令行数据,必须为该程序的绝对路径+程序完整名称
hReg.destroy;//释放创建的hReg
end;



//删除注册表项

procedure DeleteAutoRun(FileName:String);
var
reg:tregistry;
begin
reg:=tregistry.Create;
reg.rootkey:=HKEY_LOCAL_MACHINE;
reg.openkey('\Software\Microsoft\Windows\CurrentVersion\Run',true);
reg.DeleteValue(FileName); //删除注册表项
reg.CloseKey;
reg.Free;
end;

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.1027979850769 seconds