Community Forums
Results 1 to 2 of 2

Thread: Strange behavior when reading a value from windows registry

  1. #1
    Join Date
    Sep 2016
    Posts
    3

    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.

    Code:
     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

    Code:
    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

  2. #2
    Join Date
    Dec 2013
    Posts
    103
    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •