Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Root: HKLM; Subkey: "SOFTWARE\xxx\yyy"; ValueType: string ; ValueName: "KEYNAME"; ValueData: "{olddata};C:\x\y\z.dll

I am using this line of code in inno setup to open the registry path and add a.dll at the enf of the existing data. How to check if the registry value has the dll name which i want to add.

What I have tried:

i have tried using the combination of if and comparetext but didn't succeed
Posted
Updated 25-Apr-16 0:59am

1 solution

If you want to check if the key exists and read the current value, you must use Pascal Scripting[^] in the [Code][^] section. However, this requires that you become familiar with the Pascal scripting used by Inno Setup.

The function to read a string value from the registry is RegQueryStringValue[^]. You can then for example use the Pos string function to check if the value contains a specific substring or use CompareText / CompareStr to compare complete strings.

Untested example:
Delphi
var
  Value, LowerValue: String;
  Search: Integer;
begin
  if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\xxx\yyy', 'KEYNAME', Value) then
  begin
    LowerValue := Lowercase(Value);
    Search := Pos('c:\x\y\z.dll', LowerValue);
    if (Search = 0) then
    begin
       Value := Value + ';C:\x\y\z.dll';
       RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\xxx\yyy', 'KEYNAME', Value);
    end;
  else
    RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\xxx\yyy', 'KEYNAME', 'C:\x\y\z.dll');
  end;
end;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900