Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup RegKeyExists on 64 bit systems

I created a setup with Inno Setup and wanted to query the registry using Pascal Script

 if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Classes\\Installer\UpgradeCodes\342603A924F08FA4B95B5C283FC13D13') then

My setup is 32bit (as is my Software I want to install), but on 64bit systems, the query is redirected to HKCR\Wow6432Node\\Installer\UpgradeCodes

Of course, the key is not found, even though it is there. How can I detect the key even though my setup remains 32bit?

like image 814
testalino Avatar asked Dec 13 '10 14:12

testalino


1 Answers

I figured it out. You can make a helper function like this in your script:

function GetHKLM: Integer;
begin
  if IsWin64 then
    Result := HKLM64
  else
    Result := HKLM32;
end;

Then you use it like e.g.:

RegQueryStringValue(
  GetHKLM, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'XYZ', Variable);
like image 84
testalino Avatar answered Oct 22 '22 00:10

testalino