Detecting the Windows version running on your machine


The following code retrieves the current Windows Operating System name and version (with Service Packs) into a CString.

osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
CString WindowsPlatform;
if (GetVersionEx(&osv))
 // note: szCSDVersion =  service pack  release  
 CString ServiceRelease = osv.szCSDVersion;
  case VER_PLATFORM_WIN32s: //Win32s on Windows 3.1.
   WindowsPlatform = "Microsoft® Windows 3.1(TM)";

  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;
    WindowsPlatform = "Microsoft® Windows 98(TM) " + ServiceRelease;

  case VER_PLATFORM_WIN32_NT: //Win32 on Windows NT.
   WindowsPlatform = "Microsoft® Windows NT(TM) "  + ServiceRelease;

   AfxMessageBox("Failed to get correct Operating System.", MB_OK);  
 } //end switch
} //end if

Date Last Updated: March 1, 1999


  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date