Providing System Information

You can implement OEMIoControl to support IOCTL_HAL_GET_DEVICE_INFO, which provides support for SystemParametersInfo, which queries or sets system-wide parameters and updates the user profile.

When Windows CE calls OEMIoControl with IOCTL_HAL_GET_DEVICE_INFO in the dwIoControlCode parameter, the OS sets the nInBufSize parameter to 4 bytes and passes a system parameters information (SPI) code in the lpInputBuf parameter. In order to support the SPI code, OEMIoControl must support the following SPI flags:

Flag Description
SPI_GETPLATFORMTYPE Requests a string that identifies the Windows CE–based platform type. Do not localize this string.
SPI_GETOEMINFO Requests OEM-specific information. The information string can include, but is not limited to, the model name, model number, and manufacturer.

Although Windows CE does not restrict the lengths of the returned strings, long strings may be unsuitable for display on some target devices or for communicating between applications. Also, be sure to use SPI_GETPLATFORMTYPE names that are unique across Windows CE products. Some host-side applications rely on this name for configuration. Using unique names prevents target device type conflicts and ensures successful integration with other Microsoft products.

The following code example shows how to handle SPI_GETPLATFORMTYPE and SPI_GETOEMINFO requests.

// OemIoControl implementation in %_WINCEROOT%\Platform\%BSP%\Kernel\Hal\Oemioctl.c:
const WCHAR HALPlatformStr[] = L"My platform";
const WCHAR HALOEMStr[] = L"Test";

BOOL OEMIoControl(...) 
{ ...
switch (dwIoControlCode) {
case IOCTL_HAL_GET_DEVICE_INFO:
  if (nInBufSize == 4) { // contains the SPI_* code 
    switch (*(LPDWORD)lpInBuf) {
    case SPI_GETPLATFORMTYPE:
      len = (strlenW(HALPlatformStr)+1)*sizeof(WCHAR);
      if (nOutBufSize >= len) {
        memcpy(lpOutBuf,HALPlatformStr,len);
        retval = TRUE;
      } else
        SetLastError(ERROR_INSUFFICIENT_BUFFER);
      break;
    case SPI_GETOEMINFO:
      len = (strlenW(HALOEMStr)+1)*sizeof(WCHAR);
      if (nOutBufSize >= len) {
        memcpy(lpOutBuf,HALOEMStr,len);
        retval = TRUE;
      } else
        SetLastError(ERROR_INSUFFICIENT_BUFFER);
      break;
    default:
      SetLastError(ERROR_INVALID_PARAMETER);
    }
  } else {
    SetLastError(ERROR_INVALID_PARAMETER);
  }
  break; // End switch case for IOCTL_HAL_GET_DEVICE_INFO
...

See Also

How to Develop an OEM Adaptation Layer | Implementing the OEMIoControl Function

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.