将值写入 Inno Setup 中存储在数组中的所有注册表项

问题描述

我见过这个 https://jrsoftware.org/ishelp/index.php?topic=registrysection 但这不是动态的。

我读取了在注册表中找到的值,它们可以是事物的组合。并非所有客户端都拥有所有组合,因此我需要根据其系统中的内容创建注册表子项。我可以毫无问题地在子项下创建值:

for i := 0 to GetArrayLength(myarrayofstrings) - 1 do
begin
  if myarrayofstrings[i] = 'client has this item' then begin
    RegWriteStringValue(HKLM64,'SOFTWARE\SomeSubkey','New Value','im in the registry');
  end;
end;

我想要做的是根据变量 myarrayofstrings 中的值在注册表中创建一个新的子项。

if not myarrayofstrings[i] = 'client has this item' then begin
  //Create new subkey called the value in myarrayofstrings[i]
  //then add values to the newly created subkey
end;

我该怎么做?谢谢

解决方法

只需在键路径中使用 myArrayOfStrings[I] 的值:

var
  Key: string;
  I: Integer;
begin
  // ...
  for I := 0 to GetArrayLength(myArrayOfStrings) - 1 do
  begin
    Key := 'SOFTWARE\SomeSubkey\' + myArrayOfStrings[I];
    RegWriteStringValue(HKLM64,Key,'New Value 1','value 1');
    RegWriteStringValue(HKLM64,'New Value 2','value 2');
    // ...
  end;
end;