views:

698

answers:

5

Using either the registry or the file system. The reason for the restriction is that I am doing this as an MSI conditional statement.

Cheers!

+4  A: 

You should find enough information to determine the OS service pack (in the worst case you can always use the build string) in the following registry key:


HKLM\Software\Microsoft\Windows NT\CurrentVersion
emaster70
Cheers! Where exactly under this key would you find the service pack info?
Duncan Edwards
In Service Pack 3 you should expect to find a key named CSDVersion with value "Service Pack 3"
emaster70
+1  A: 

The VerifyVersionInfo function should allow you to check the version of Windows being run meets your application's requirements, without the pitfalls that can occur with checking for an exact version with GetVersionEx (such as breaking on major version changes - your application will most likely run on Vista, and Windows 7, and future versions not yet developed).

Jason Owen
A: 

Have you considered using library like DTWinver? It can detect version and various features of operating systems ...

Jiri
+3  A: 

under registry key

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion

look for key pair:

CurrentVersion = Microsoft Windows NT 5.1.2600 Service Pack 3

kloucks
CSDVersion key has a "Service Pack n" value. Which is good enough for what I need.
Duncan Edwards
A: 

If you're using an MSI, you should be able to use the VersionNT and ServicePackLevel properties right in the conditional statement.

eg. The following code checks for Windows XP sp3 or greater:

VersionNT=501 And ServicePackLevel>2

You can also check the WindowsBuild property if you also need the build number.

CodeSavvyGeek