delphi 遍历 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run 所有项目
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, System.Win.Registry;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure ListAutoStartItems;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ListAutoStartItems;
var
Reg: TRegistry;
ValueNames: TStringList;
I: Integer;
Value: string;
begin
Reg := TRegistry.Create;
ValueNames := TStringList.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKeyReadOnly('Software\Microsoft\Windows\CurrentVersion\Run') then
begin
Reg.GetValueNames(ValueNames);
Memo1.Lines.Add('Auto-start items:');
for I := 0 to ValueNames.Count - 1 do
begin
Value := Reg.ReadString(ValueNames[I]);
Memo1.Lines.Add(ValueNames[I] + ' = ' + Value);
end;
Reg.CloseKey;
end;
finally
Reg.Free;
ValueNames.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ListAutoStartItems;
end;
end.
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.11778020858765 seconds