Operating System Version Information

< BACK  NEXT >
[oR]

The function GetVersionEx can be used to obtain the Windows CE operating system version your application is running on. The function takes a single argument that is a pointer to a OSVERSIONINFO structure in which the version information is returned. The code in Listing 13.1 calls GetVersionEx and displays the contents of the OSVERSIONINFO structure.

Listing 13.1 Obtaining operating system version information
 void Listing13_1() {    OSVERSIONINFO osVersion;    osVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);    if(!GetVersionEx(&osVersion))        cout   _T("Could not get version information")               endl;    else    {       cout   _T("Major Version:")              osVersion.dwMajorVersion   endl;       cout   _T("Minor Version:")              osVersion.dwMinorVersion   endl;       cout   _T("Build:")              osVersion.dwBuildNumber   endl;       cout   _T("Platform ID:")              osVersion.dwPlatformId   endl;       cout   _T("Other Info:")              osVersion.szCSDVersion   endl;    } } 

Output for a Pocket PC device should look something like the following:

 Major Version: 3 Minor Version: 0 Build:9348 Platform ID: 3 Other Info: 

This Pocket PC device is running Windows CE 3.0, build number 9348. Your devices are likely to be running a later build number. The value 3 for platform id indicates that this is Windows CE. Other values are used for Windows NT/98/2000. The szCSDVersion member is usually blank.

The SystemParametersInfo Function

The SystemParametersInfo function can be used to obtain and set many different system parameters, such as the platform type string (indicating the type of Windows CE device), OEM information (to determine the manufacturer of the device), and the idle timeout (how long Windows will remain on before suspending when there is no activity).

The SystemParametersInfo function is passed four parameters:

  • A constant indicating the information to be returned or set.

  • A UINT value, the nature of which depends on the information being returned or set.

  • A PVOID pointer, the nature of which depends on the information being returned or set.

  • A Boolean value, which if TRUE causes a WM_SETTINGCHANGE message to be sent to all top-level windows. This value should be 0 if information is only being returned.

In Listing 13.2, the function SystemParametersInfo is called twice, once to return the OEM information (SPI_GETOEMINFO) and again to return the platform information (SPI_GETPLATFORMTYPE). In both cases, the function is passed a buffer length as the second parameter, and a pointer to a string buffer into which the information will be placed as the third.

Listing 13.2 SystemParametersInfo
 void Listing13_2() {    TCHAR szOEMInformation[200];    TCHAR szPlatformType[200];    SystemParametersInfo(SPI_GETOEMINFO,           200, szOEMInformation, 0);    cout   _T("OEM Information: ")          szOEMInformation   endl;    SystemParametersInfo(SPI_GETPLATFORMTYPE,           200, szPlatformType, 0);    cout   _T("Platform Type: ")          szPlatformType   endl; } 

The SPI_GETOEMINFO information will be something like "Compaq Aero 1500," and for a Pocket PC device, SPI_GETPLATFORMTYPE returns "Palm PC2." For handheld devices, SPI_GETPLATFORMTYPE returns "H/PC."


< BACK  NEXT >


Windows CE 3. 0 Application Programming
Windows CE 3.0: Application Programming (Prentice Hall Series on Microsoft Technologies)
ISBN: 0130255920
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net