Inno - prevent registry keys being redirected to t

2019-02-20 10:02发布

问题:

This question already has an answer here:

  • Inno Setup does not seem to write to the registry on a 64-bit machine 1 answer

In my Inno installer I am writing some registry keys:

RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Google\Chrome\NativeMessagingHosts\com.mycompany.myapp', '', ExpandConstant('{app}\{#MyAppChrome}'));
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Mozilla\NativeMessagingHosts\com.mycompany.myapp', '', ExpandConstant('{app}\{#MyAppChrome}'));

It automatically writes it to the keys under Wow6432Node, which is fine. But firefox expects it not be under Wow6432Node:

Windows

For global visibility, create a registry key with the following name:

HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\NativeMessagingHosts\ The key should have a single default value, which is the path to the manifest.

Note that this key should not be created under Wow6432Node, even if the app is 32-bit. The browser will always look for the key under the "native" view of the registry, not the 32-bit emulation. To ensure that the key is created in the "native" view, you can pass the KEY_WOW64_64KEY or KEY_WOW64_32KEY flags into RegCreateKeyEx. See Accessing an Alternate Registry View.

So, how can I prevent the redirection of firefox related registry key.

回答1:

If you install a 64-bit application on 64-bit Windows then you can change everything to 64-bit mode:

[Setup]
ArchitecturesInstallIn64BitMode=x64

If you install a 32-bit application on 64-bit Windows then you can perform a specific write to the 64-bit registry view with a HK*64 registry root:

[Registry]
Root: HKLM64; Subkey: "Software\..."; ValueType: String; ValueData: "{app}..."; Flags: uninsdeletekey; Check: IsWin64
Root: HKLM; Subkey: "Software\..."; ValueType: String; ValueData: "{app}..."; Flags: uninsdeletekey; Check: not IsWin64

You can also use if IsWin64 then ... if you prefer Pascal scripting.