This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Strange behavior when reading a value from windows registry
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
Sep 12, 2017
10:32 AM
Strange behavior when reading a value from windows registry
I am facing a strange problem when trying to read a value from windows registry using a InstallScript function. I have created a InstallScript MSI Project and have written the following function to get Java 6 path from the registry.
The problem is that this works like a charm in some windows 7 machines but does not work in some other windows 7 machines and svValue sets to empty string, however the path exists in the registry. The strange thing is that in the machines that it does not work I checked some other paths and the function works for some paths and doesn’t work for some others! For example I tried to read a value from another path using the following settings
and it works. I emphasis that all ot the tested paths exist in the registry but for some of them RegDBGetKeyValueEx sets empty string in svValue. I am really stuck on this and any help would be appreciated.
Anyway I use 64 bit windows 7 machines, InstallShield 2015, InstallScript MSI Project, and use the Administrator user for test.
Regards,
Ferez
function getJavaHome(hMSI)
STRING szKey, szName, svValue, szMsg;
NUMBER nvSize, nvType;
begin
szName = "JavaHome";
szKey = "\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.6";
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
if (RegDBGetKeyValueEx(szKey, szName, nvType, svValue, nvSize) < 0) then
szKey = "\\SOFTWARE\\Wow6432Node\\JavaSoft\\Java Runtime Environment\\1.6";
RegDBGetKeyValueEx(szKey, szName, nvType, svValue, nvSize);
endif;
MsiSetProperty(hMSI, "JAVAHOME", svValue);
MessageBox("Registry value is: " + svValue, INFORMATION);
end;
The problem is that this works like a charm in some windows 7 machines but does not work in some other windows 7 machines and svValue sets to empty string, however the path exists in the registry. The strange thing is that in the machines that it does not work I checked some other paths and the function works for some paths and doesn’t work for some others! For example I tried to read a value from another path using the following settings
szName = "InstallPath";
szKey = "\\SOFTWARE\\Adobe\\Adobe Bridge\\CS6\\Installer";
and it works. I emphasis that all ot the tested paths exist in the registry but for some of them RegDBGetKeyValueEx sets empty string in svValue. I am really stuck on this and any help would be appreciated.
Anyway I use 64 bit windows 7 machines, InstallShield 2015, InstallScript MSI Project, and use the Administrator user for test.
Regards,
Ferez
- Tags:
- registry
(1) Reply
Sep 13, 2017
02:04 PM
think you need to just modify the options:
if (SYSINFO.bIsWow64 != 0) then
REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY;
endif;
and lose the WOW6432 in the specified key names
if (SYSINFO.bIsWow64 != 0) then
REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY;
endif;
and lose the WOW6432 in the specified key names