Writing values to all registry keys stored in an array in Inno Setup

Viewed 75

I have seen this https://jrsoftware.org/ishelp/index.php?topic=registrysection but this isn't dynamic.

I read values found in the registry and they can be a combination of things. All clients will not have all combos, so I need to create registry subkeys based on what is in their system. I can create values under subkeys with no problem:

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;

What I want to do is create a new subkey in the registry based on the values in the variable 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;

How do I do that? Thanks

1 Answers

Just use the value of myArrayOfStrings[I] in the key path:

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, Key, 'New Value 2', 'value 2');
    // ...
  end;
end;
Related