I am new to IntallShield and extending a sizeable InstallScript project to add a new custom registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Company\Product\Foo
) and values regarding a feature on first install.
Based on the project's existing code to add other custom registry keys and values, I added a dedicated function with calls to RegDBCreateKeyEx
and RegDBSetKeyValueEx
where appropriate...
function BOOL RegisterFooFeature(szBar, szBaz)
string szValue;
number nType, nSize;
begin
RegDBSetDefaultRoot(gnProductRegRootKey); // gnProductRegRootKey = HKEY_LOCAL_MACHINE
//
// registry subkey
//
if (RegDBKeyExist(gszFooFeatureRegSubkey) < 0) then // gszFooFeatureRegSubkey = "SOFTWARE\\Company\\Product\\Foo"
if (RegDBCreateKeyEx(gszFooFeatureRegSubkey, gszProductRegClass) < 0) then
My_AddToLog("RegisterFooFeature: Unable to create registry key " + gszFooFeatureRegSubkey + ".");
return FALSE;
else
My_AddToLog("RegisterFooFeature: Created registry key " + gszFooFeatureRegSubkey + ".");
endif;
else
My_AddToLog("RegisterFooFeature: Found existing registry key " + gszFooFeatureRegSubkey + ".");
endif;
//
// registry values
//
nType = REGDB_STRING;
nSize = -1;
if (RegDBSetKeyValueEx(gszFooFeatureRegSubkey, gszBarRegValueName, nType, szBar, nSize) < 0) then
My_AddToLog("RegisterFooFeature: Unable to set registry value \"" + gszFooFeatureRegSubkey + "\\" + gszBarRegValueName + "\" to \"" + szBar + "\".");
return FALSE;
else
My_AddToLog("RegisterFooFeature: Set registry value \"" + gszFooFeatureRegSubkey + "\\" + gszBarRegValueName + "\" to \"" + szBar + "\".");
endif;
if (RegDBSetKeyValueEx(gszFooFeatureRegSubkey, gszBazRegValueName, nType, szBaz, nSize) < 0) then
My_AddToLog("RegisterFooFeature: Unable to set registry value \"" + gszFooFeatureRegSubkey + "\\" + gszBazRegValueName + "\" to \"" + szBaz + "\".");
return FALSE;
else
My_AddToLog("RegisterFooFeature: Set registry value \"" + gszFooFeatureRegSubkey + "\\" + gszBazRegValueName + "\" to \"" + szBaz + "\".");
endif;
return TRUE;
end;
...and added a call to it in OnFirstUIBefore
.
I confirmed through my logging that OnFirstUIBefore
executes on first install like I expect; and my logging indicates that the new custom registry key (HKEY_LOCAL_MACHINE\SOFTWARE\Company\Product\Foo
) and its values are created; but I do not see the new custom key and its values in the registry like I do the existing custom keys and values after first install.
Where is my new custom registry key?
It turned out that before OnFirstUIBefore
called RegisterFooFeature
it called a preexisting function that removed REGDB_OPTION_WOW64_64KEY
...and did not restore it before it returned.
I was looking for the new key and its values in the 64-bit registry hive, but they were in the 32-bit registry hive - under SOFTWARE\Wow6432Node
- due to the side effect of the preexisting function.