1

I need to get a simple description of the OS, such as "Windows XP (SP2)" or "Windows 2000 Professional" to include in some debugging code. Ideally, I'd like to simply retrieve it by calling a "GetOSDisplayName" function.

Is there such a function available for C++ win32 programming?

Colen
  • 13,428
  • 21
  • 78
  • 107

5 Answers5

4

Have a look at this: http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx

Nick Bedford
  • 4,365
  • 30
  • 36
3

If you are looking for the productName+version that marketing uses, it's in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Product Name

Looking at my computer, it says "Windows 8.1 Pro".

G Huxley
  • 1,130
  • 14
  • 19
1

and also have a look at this: http://www.codeproject.com/KB/macros/winver_macros.aspx

didito
  • 748
  • 7
  • 17
0

And here's an example from something I came across recently:

OSVERSIONINFO osvi;

ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

GetVersionEx(&osvi);
// use osvi.dwMajorVersion and osvi.dwMinorVersion

You'll need to run some tests to check which versions of windows the numbers correspond to. this might help: http://en.wikipedia.org/wiki/History_of_Microsoft_Windows#Windows_NT

// (bad) example to check if we're running Windows XP
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
{
    // Windows XP
}
Josh
  • 3,540
  • 1
  • 21
  • 12
0

Please find below a link to a related .NET question and set of answers. The C++/Win32 answer is essentially the same after some trivial mapping between .NET and C++/Win32.

How to translate MS Windows OS version numbers into product names in .NET?

Community
  • 1
  • 1
Thomas Bratt
  • 48,038
  • 36
  • 121
  • 139