0

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?

J0e3gan
  • 8,740
  • 10
  • 53
  • 80
  • 2
    You may need to look under `SOFTWARE\Wow6432Node` if your installer is 32bit running on a 64-bit OS – Blorgbeard Apr 23 '14 at 04:41
  • Got it. I am testing the installer on Windows Server 2008 R2 x64 Edition and confirmed that the installer is 32-bit using [`DUMPBIN`](http://stackoverflow.com/a/3899746/1810429). – J0e3gan Apr 23 '14 at 05:15
  • @Blorgbeard: Sorry that I did not address my previous comment to you. Your suggestion was spot-on. An existing function that `OnFirstUIBefore` called just before `RegisterFooFeature` 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 part of the registry, but they were in the 32-bit part of the registry - under `SOFTWARE\Wow6432Node` as you suspected. – J0e3gan Apr 23 '14 at 14:37
  • Cool, glad to hear you sorted it out! – Blorgbeard Apr 23 '14 at 19:43

1 Answers1

1

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.

J0e3gan
  • 8,740
  • 10
  • 53
  • 80