Getting the System Version

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 );

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database