- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- Create a 64-bit Windows Registry Entry via an InstallScript Custom Action
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
Create a 64-bit Windows Registry Entry via an InstallScript Custom Action
Create a 64-bit Windows Registry Entry via an InstallScript Custom Action
Summary
Create a 64-bit Windows Registry Entry via an InstallScript Custom Action
Cause
When creating a Windows Registry entry using an InstallScript custom action, by default, the custom action will create the entry under WOW6432Node, which is a 32-bit Windows Registry location.
Resolution
If a user specifically wants to create a Windows Registry entry under a 64-bit Windows Registry location, the user should disable WOW64 Windows Registry Redirection using REGDB_OPTIONS as follows:
#define TITLE_TEXT "RegDBCreateKeyEx & RegDBKeyExist"
#define TITLE "RegDBSetKeyValueEx & RegDBGetKeyValueEx"
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
export prototype ExFn_RegDBCreateKeyEx(HWND);
function ExFn_RegDBCreateKeyEx(hMSI)
STRING szKey, szClass, szKeyRoot, szMsg, szAppCount, svLogFile,szRegName;
NUMBER nResult1, nResult2;
begin
// Disable WOW64 Windows Registry redirection
REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY;
// Disable WOW64 file system redirection
Disable(WOW64FSREDIRECTION);
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
//szKey = INSTALL_REGISTRY_KEY;
szKey = "SOFTWARE\\ISTest";
if (RegDBCreateKeyEx(szKey, szClass) < 0) then
MessageBox ("First call to RegDBCreateKeyEx failed.", SEVERE);
abort;
else
SprintfBox (INFORMATION, TITLE_TEXT, "Successfully created: %s", szKey);
// Check to see if the key just created exists.
if (RegDBKeyExist (szKey) < 0) then
MessageBox ("First call to RegDBKeyExist failed.", SEVERE);
else
SprintfBox (INFORMATION, TITLE_TEXT, "%s exists.", szKey);
endif;
endif;
szAppCount ="ISTesting";
szRegName = "ApplicationCount";
nResult1 = RegDBSetKeyValueEx(szKey,szRegName, REGDB_STRING, szAppCount, -1);
if ((nResult1 <0)) then
MessageBox ("RegDBSetKeyValueEx failed.", SEVERE);
abort;
else
// Display what RegDBSetKeyValueEx has done.
szMsg = "%s set to: %s";
SprintfBox (INFORMATION, TITLE, szMsg, szRegName, szAppCount);
endif;
// Enable WOW64 file system redirection
Enable(WOW64FSREDIRECTION);
// Enable WOW64 Windows Registry redirection
REGDB_OPTIONS = REGDB_OPTIONS & ~REGDB_OPTION_WOW64_64KEY
end;
Reference
Click here for more information about the InstallScript RegDBCreateKeyEx function.
Click here for an example of how to call the InstallScript RegDBCreateKeyEx function.
Click here for more information about the InstallScript RegDBSetKeyValueEx function.
Click here for an example of how to call the InstallScript RegDBSetKeyValueEx function.
Click here for more information about the InstallScript REGDB_OPTIONS function.
Click here for more information about the InstallScript Enable function.
Click here for more information about the InstallScript Disable function.
A ZIP file containing a sample project is attached. The sample project is configured to execute the InstallScript custom action during the Execute Sequence of the install with a condition of Not Installed. The condition configures the custom action to only run during a clean, fresh, first-time install.