Hello AskPerf readers. My name is Scott McArthur and I am a Support Escalation Engineer with the Setup & Cluster team. I know you’re probably thinking that one of us has somehow found our way to the wrong blog! I recently ran into an interesting scenario while working on a customer issue, and since this has some impact on Application Compatibility, I figured AskPerf would be the best place to write about it.
The customer’s issue I was working on dealt with an application install failure on a 64-bit installation of Windows Vista. The application in question required Windows Vista Service Pack 1 as a prerequisite for installation, and the system administrator duly installed SP1 and then proceeded to launch the installation of the application. And then, a funny thing happened – the application returned an error, indicating that Service Pack 1 for Windows Vista was not installed. According to the Windows Update logs, the SP1 installation appeared to have completed without incident. Trying the installation of the application on another machine, the administrator found that he encountered the same problem on every Windows Vista SP1 machine. As Alice said, while in Wonderland, “curiouser and curiouser” …
It turned out that the problem wasn’t with the installation of Service Pack 1. The problem lay in the method being used by the application to check the OS and Service Pack version. The application was checking for the OS version in a registry value, specifically: HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\CSDVersion. On the x64 version of Windows Vista Service Pack 1, however this value does not exist. The correct value does show up under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CSDVersion however. This highlights an inherent problem with relying on the registry method to capture this information. As operating systems evolve, there is no guarantee that registry information will persist between operating systems, or in some cases there may be changes between service packs for the same operating system.
When determining OS versions for application installs, a better method than reading the registry would be to either use a WMI query or to use an API. The GetVersionEx function is designed to retrieve this information and is not affected by change. One caveat though – if you are testing for whether a particular feature is installed, the GetVersionEx function would not be the best approach. With that in mind, below are some items returned by using this function that are specific to Service Packs:
- szCSDVersion: A null-terminated string, such as "Service Pack 3", that indicates the latest Service Pack installed on the system. If no Service Pack has been installed, the string is empty.
- wServicePackMajor: The major version number of the latest Service Pack installed on the system. For example, for Service Pack 3, the major version number is 3. If no Service Pack has been installed, the value is zero.
- wServicePackMinor: The minor version number of the latest Service Pack installed on the system. For example, for Service Pack 3, the minor version number is 0.
And on that note, we’ve reached the end of this post. Thanks for dropping by!
– Scott McArthur