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 setwindowshookex - 设置钩子 unhookwindowshookex - 卸掉钩子

Delphi 远程屏幕抓取的源代码

Delphi tzipfile 用法

Delphi判断线程是否释放

Delphi webbrowser 释放注意事项

Delphi中文件名函数-路径、名称、子目录、驱动器、扩展名

Delphi idpop3收邮件

Delphi 关于access的日期类型字段比较的一点认识

Delphi thread类的创建及使用(关于线程函数的传递例子)

Delphi 无类型文件读写

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



打赏

取消

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

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

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

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

评论

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

    正在狠努力加载,请稍候...