uses
Registry;
在 Form 上放一個 TMemo
在 FormCreate 事件中加入
procedure TForm1.FormCreate(Sender: TObject);
const
key = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Run'; // Registry Key
var
i: Integer;
Registry: TRegistry;
Strings: TStrings;
Name: string;
begin
Memo1.Clear;
Strings := TStringList.Create;
Registry := TRegistry.Create;
try
Memo1.Lines.Add('<< HKEY_CURRENT_USER >>');
Registry.RootKey := HKEY_CURRENT_USER;
Registry.OpenKey(key, False);
Registry.GetValueNames(Strings);
for i := 0 to Strings.Count -1 do
begin
Name := Strings[i];
Memo1.Lines.Values[Name] := Registry.ReadString(Name);
end;
Registry.CloseKey;
Memo1.Lines.Add('<< HKEY_LOCAL_MACHINE >>');
Registry.RootKey := HKEY_LOCAL_MACHINE;
Registry.OpenKey(key, False);
Registry.GetValueNames(Strings);
for i := 0 to Strings.Count -1 do
begin
Name := Strings[i];
Memo1.Lines.Values[Name] := Registry.ReadString(Name);
end;
Registry.CloseKey;
finally
Registry.Free;
Strings.Free;
end;
end;
沒有留言:
張貼留言