Question

I have some free-standing C++ code (i.e. not a Windows program) that needs to identify the version of Windows that is installed on a PC.

I can easily differentiate between the different Windows client releases by kernel version (e.g. GetFileVersionInfo on ntoskrnl.exe), however I'm wondering if there's a reliable way to distinguish between a client and server installation.

A problem arises when using this method to distinguish between Windows Vista SP2 and Windows Server 2008 SP2 (6.0 build 6002 the both of them) and Windows 7 and Windows Server 2008 R2 (6.1 build 7600 for RTM and 6.1 build 7601 for SP2, both). What is a reliable (and preferably as straight forward as possible, avoiding the registry would be great as access to Win32 API is not available) method of identifying client vs server OSes correctly for code running outside the environment?

I suppose I could check for files only present on the server edition (what's a good file guaranteed to be on any server edition install, regardless of configuration?), check the Panther folder (which is safe to delete, so no guarantees there), etc. but I'm sure this is a problem that people have run into before and (hopefully) solved more elegantly?

(Sidenote: this question has been asked on SO before, but the solution (WMI) is inapplicable for out-of-band checking)

Was it helpful?

Solution 3

I ended up searching for a number of binaries in the system32 directory that are generally associated with the Server Edition of Windows. It's not very clean, but in practice it works very well.

OTHER TIPS

I'm not entirely sure what you mean about out of band checking, so I'm going to ignore that for the moment.

The normal way would be to call GetVersionEx, and look at the wProductType member of the OSVERSIONINFOEX.

A PE image does NOT specify whether the image should work on a client or server. It only specifies the runtime requirements regarding subsystem, dependencies, memory, affinity, etc...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top