cancel
Showing results for 
Search instead for 
Did you mean: 
farzad_itm
Pilgrim

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.

 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
Labels (1)
Tags (1)
0 Kudos
1 Reply
TurboFisch
Pilgrim

Re: Strange behavior when reading a value from windows registry

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
0 Kudos