开发者

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 th开发者_开发问答ough my setup remains 32bit?


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜