Detecting the Windows version running on your machine
Posted
by Rob Fullington
on March 1st, 1999
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
CString WindowsPlatform;
if (GetVersionEx(&osv))
{
// note: szCSDVersion = service pack release
CString ServiceRelease = osv.szCSDVersion;
switch(osv.dwPlatformId)
{
case VER_PLATFORM_WIN32s: //Win32s on Windows 3.1.
WindowsPlatform = "Microsoft® Windows 3.1(TM)";
break;
case VER_PLATFORM_WIN32_WINDOWS: //WIN32 on 95 or 98
//determine if Win95 or Win98
if (osv.dwMinorVersion == 0)
{
WindowsPlatform = "Microsoft® Windows 95(TM) " + ServiceRelease;
}
else
{
WindowsPlatform = "Microsoft® Windows 98(TM) " + ServiceRelease;
}
break;
case VER_PLATFORM_WIN32_NT: //Win32 on Windows NT.
WindowsPlatform = "Microsoft® Windows NT(TM) " + ServiceRelease;
break;
default:
AfxMessageBox("Failed to get correct Operating System.", MB_OK);
} //end switch
} //end if
Date Last Updated: March 1, 1999

Comments
New for VS.NET
Posted by Legacy on 01/20/2004 12:00amOriginally posted by: Patrick
New Macros built in (and GetVersionEx disappeared) in VS.NET (2k3)
/* From MSDN
_osver - Current Build Number
_winmajor - Major Version Number
_winminor - Minor Version Number
-winver - Holds value of _winmajor in high byte and the value of _winminor in low byte
*/
So, just use it with the case/switch statements shown earlier and you should be fine.
Patrick
ReplyHow to get Windows registration number in Windows 2000?
Posted by Legacy on 11/27/2002 12:00amOriginally posted by: Cham
How to get Windows registration number in Windows 2000?
ReplyUpdate From Microsoft
Posted by Legacy on 10/16/2002 12:00amOriginally posted by: Stephen Love
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
Here is an update streight from microsoft
ReplyRemote...
Posted by Legacy on 09/13/2002 12:00amOriginally posted by: Rob
Hi all,
is there a possibility to get the platform info via remote ?
I think, there is one, but I don�t find it..:-)
THX!
ReplyRob.
HELP!!! HOW TO DO THIS!!
Posted by Legacy on 08/15/2002 12:00amOriginally posted by: James
may i know how to get the codes going? please help!!
ReplyFound another way of determining the current Operating system..
Posted by Legacy on 07/03/2001 12:00amOriginally posted by: Ian Montgomery
ReplyNT server detection is added
Posted by Legacy on 11/30/2000 12:00amOriginally posted by: Alexander
ReplySample Project
Posted by Legacy on 04/08/2000 12:00amOriginally posted by: Ron
Do you have sample Projects????
ReplyAddon for Windows version check.
Posted by Legacy on 12/22/1999 12:00amOriginally posted by: Joakim Fredlund
Reply