How to get the Windows OS version

31 12 2008

Microsoft divides its Operating System version numbers into two parts, Major Version Number and Minor Version Number.

Please look on the following table that summarizes the most recent operating system version numbers,

Operating system Version number
Windows Server 2008 6.0
Windows Vista 6.0
Windows Server 2003 R2 5.2
Windows Server 2003 5.2
Windows XP 5.1
Windows 2000 5.0

Now wats next step, we need to get our OS version number.

Just use the windows API function GetVersion. This function retrieves the major and minor version numbers and other information about the currently running version of the operating system.

Please check the code snippet below.

void CheckOSVersion()
   DWORD dwVersion, dwMajorVersion, dwMinorVersion, dwBuild;
   dwVersion = ::GetVersion();
   // Gets the Major version
   dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
   // Gets the Minor version
   dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
   // Get the build number. 
   if (dwVersion < 0x80000000)            
      dwBuild = (DWORD)(HIWORD(dwVersion));
   else    // Windows Me/98/95
      dwBuild =  0;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: