The following example uses the GetVersionEx function to obtain the current version of Windows and then displays the version number in a message box.
OSVERSIONINFO osvi;
char szVersion [80];
memset(&osvi, 0, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
GetVersionEx (&osvi);
if (osvi.dwPlatformId == VER_PLATFORM_WIN32s)
wsprintf (szVersion, "Microsoft Win32s %d.%d (Build %d)",
osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.dwBuildNumber & 0xFFFF);
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
wsprintf (szVersion, "Microsoft Windows 95 %d.%d (Build %d)",
osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.dwBuildNumber & 0xFFFF);
else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
wsprintf (szVersion, "Microsoft Windows NT %d.%d (Build %d)",
osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.dwBuildNumber & 0xFFFF);
MessageBox( NULL, szVersion, "Version Check", MB_OK );