GetVersion

2.x

  DWORD GetVersion(void)    

The GetVersion function retrieves the current version numbers of the Windows and MS-DOS operation systems.

Parameters

This function has no parameters.

Return Value

The return value specifies the major and minor version numbers of Windows and of MS-DOS, if the function is successful.

Comments

The low-order word of the return value contains the version of Windows, if the function is successful. The high-order byte contains the minor version (revision) number as a two-digit decimal number. For example, in Windows 3.1, the minor version number is 10. The low-order byte contains the major version number.

The high-order word contains the version of MS-DOS, if the function is successful. The high-order byte contains the major version; the low-order byte contains the minor version (revision) number.

Example

The following example uses the GetVersion function to display the Windows and MS-DOS version numbers:

int len;
char szBuf[80];
DWORD dwVersion;

dwVersion = GetVersion();

len = sprintf(szBuf, "Windows version %d.%d\n",
    LOBYTE(LOWORD(dwVersion)),
    HIBYTE(LOWORD(dwVersion)));

sprintf(szBuf + len, "MS-DOS version %d.%d",
    HIBYTE(HIWORD(dwVersion)),
    LOBYTE(HIWORD(dwVersion)));

MessageBox(NULL, szBuf, "GetVersion", MB_ICONINFORMATION);

Note that the major and minor version information is reversed between the Windows version and MS-DOS version.