Delphi开机启动项管理源码


本文整理自网络,侵删。

 uses Registry; //引用注册表操作类

var
Form1: TForm1;
reg: TRegistry;
Names: TStringList;
i: Integer;

Const
MKey='\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'; //定义要打开的键值常量

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
Names:= TStringList.Create; //读取启动项
reg:= TRegistry.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
if reg.OpenKey(MKey,False) then
begin
Reg.GetValueNames(Names);
Listview1.Clear;
for i:=0 to Names.Count -1 do
begin
with Listview1.Items.Add do
begin
caption:=Names[i];
SubItems.Add(reg.ReadString(Names[i]));
end;
end;
reg.CloseKey;
end;
Names.Free;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
with listview1 do
begin
columns.Items[0].Width:=100;
columns.Items[1].Width:=350;
Button1.Click;
end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
DelKey: string;

begin
reg:= TRegistry.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE; //删除选中的注册表启动项
if reg.OpenKey(MKey,False) then
begin
DelKey:=Listview1.Selected.Caption;
reg.DeleteValue(DelKey);
reg.CloseKey;
listview1.DeleteSelected;
end;
end;

end.

相关阅读 >>

Delphi 设置系统默认打印机

Delphi根据输入日期按年月周日输出日期段

Delphi的unicode与gb2312转转换,汉字unicode转gb2312

Delphi版pspterminateprocess驱动源码

Delphi 下载网页

Delphi 从字符串中提取单词、从字符串中提取汉字的函数

Delphi获取星期几

如何在 Delphi 中静态链接 sqlite

Delphi tfilestream 逐行读取文本

Delphi xe 获取android的路径信息

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



打赏

取消

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

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

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

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

评论

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