InstallShield Tips and Techniques

August 11, 2013

Issue with determining Service Pack on Windows 7 64bit OS

Filed under: Reference Materials — shieldmaster @ 2:26 am

Recently I needed to display the Service Pack that was installed on the Operating System. Traditionally I would use the embedded InstallScript command:

nSPValue = (SYSINFO.WINNT.nServicePack);

But for an unknown reason, this was not working for Windows 7 (64bit machines). I decided to go back to basics and retrieve the Service pack value directly from the registry. Since InstallShield Custom Actions are embodied within a 32bit DLL during execution, when you are reading the 64bit section of the registry, you will need to shut off Registry Redirection – otherwise you would be reading the Wow6432Node section. Here is the working InstallScript that reads in the Service Pack from the registry. The value contained in the registry is “Service Pack X” – but I just needed the SP value for my customer dialog, so I added additional script to parse the value:

if (SYSINFO.bIsWow64) then

    //Turn off Registry Redirection if 64bit

    //  Specifies that all future general registry operations affect the 64-bit parts of the registry 

    //  instead of the 32-bit parts of the registry (on a 64-bit system). 

    

    REGDB_OPTIONS = REGDB_OPTION_WOW64_64KEY;      

endif;

 

        // Retrieve the Service Pack

            RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); 

            szRegKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";

            szRegSubKey = "CSDVersion";    // "Service Pack 1"

            nvType = REGDB_STRING;

            nResult = RegDBGetKeyValueEx(szRegKey, szRegSubKey, nvType, szSPLiteral, nvSize) ;

            StrSub (szSPValue, szSPLiteral,13, 1);

            StrToNum (nSPValue, szSPValue);

 

if (SYSINFO.bIsWow64) then

    //Turn off Registry Redirection if 64bit

    //  Specifies that all future general registry operations affect the 64-bit parts of the registry 

    //  instead of the 32-bit parts of the registry (on a 64-bit system). 

    

    REGDB_OPTIONS = REGDB_OPTIONS & ~REGDB_OPTION_WOW64_64KEY ;      

endif;

 

Sometimes you just got to go back to basics!

 

Shieldmaster

Advertisements

4 Comments »

  1. Was there a reason you couldn’t use the ServicePackLevel property? http://msdn.microsoft.com/en-us/library/windows/desktop/aa370556(v=vs.85).aspx

    Comment by Doc — August 11, 2013 @ 6:55 am

    • Honestly, I did not realize that there was a corresponding MSI Property for the Service Pack! When I added this script:
      nzSize = 256;
      MsiGetProperty (ISMSI_HANDLE, “ServicePackLevel”, szWinBuild, nzSize);

      The correct Service Pack was retrieved!

      Thanks for the tip!
      Charles

      Comment by shieldmaster — August 11, 2013 @ 2:00 pm

      • Glad to help. The OS properties have always proved useful over the years.

        Comment by Doc — August 11, 2013 @ 3:50 pm

  2. Thanks for sharing!! Here I info to make shortcuts run as administer and run in compatibility mode. I want updates..

    Comment by Tomas Alva — April 2, 2016 @ 7:26 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: