Reputation: 13898
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?
Upvotes: 1
Views: 4142
Reputation: 1147
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".
Upvotes: 4
Reputation: 51764
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?
Upvotes: 0
Reputation: 3596
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
}
Upvotes: 1
Reputation: 738
and also have a look at this: http://www.codeproject.com/KB/macros/winver_macros.aspx
Upvotes: 1
Reputation: 4435
Have a look at this: http://msdn.microsoft.com/en-us/library/ms724429(VS.85).aspx
Upvotes: 4