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;

相关阅读 >>

Delphi xe5 android 黑屏的临时解决办法

Delphi实例之一个较复杂的记事本的实现

Delphi idhttp post中文的问题

Delphi 查找某函数在某个单元

Delphi字符串加密解密

Delphi 取键盘值

Delphi 主程序与dll之间的全局变量问题

Delphi 结束360safe和360保险箱进程 for Delphi

Delphi xe android]获取屏幕的物理分辨率

Delphi 根据注册表信息判断程序是否安装

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...