使用名称读取所有注册表值

Hyp*_*erX 0 delphi pascal

我正在编写一个用Delphi转换的程序,旧程序保存了文件路径.所以我必须得到这些文件,他们的路径在注册表中,如下所示:

HKEY_LOCAL_MACHINE -> SOFTWARE-> Company->Program-> Pos1, Stack, Pop
Run Code Online (Sandbox Code Playgroud)

所以计划下有喜欢的几个籍图Pos1,Stack,Pop等,他们每个人都有属性有所谓的WorkStation是路径,我需要得到.所以我在寻找是否有办法扫描所有的东西并获得这条路径?或者我是否需要了解注册表的每个路径?

STB*_*and 5

要枚举所有子键名称,可以使用单元中类的GetKeyNames()方法.然后,您可以遍历子键,打开每个子键并读取其值.TRegistryRegistryWorkStation

uses
  ...,
  Registry,
  Classes;

var
  registry : TRegistry;
  subKeysNames : TStringList;
  WorkStation : String;
  i : Integer;
begin
  registry := TRegistry.Create;
  try
    subKeysNames := TStringList.Create; 
    try
      registry.RootKey := HKEY_LOCAL_MACHINE;
      if registry.OpenKeyReadOnly('\Software\Company\Program') then
      begin
        registry.GetKeyNames(subKeysNames);
        CloseKey;
      end;
      for i := 0 to subKeysNames.Count - 1 do
      begin
        if registry.OpenKeyReadOnly('\Software\Company\Program\' + subKeysNames[i]) then
        begin
          WorkStation := registry.ReadString('WorkStation');
          registry.CloseKey;
          if WorkStation <> '' then
          begin
            // use WorkStation as needed...
          end;
        end;
      end;
    finally
      subKeysNames.Free;
    end;
  finally
    registry.Free; 
  end;
end;
Run Code Online (Sandbox Code Playgroud)