INFO: Windows 98: Set Power Management with _VPOWERD_Get_Mode

ID: Q230470


The information in this article applies to:


SUMMARY

VxDs running under Windows 98 can use the _VPOWERD_Get_Mode service to determine the power management mode of the system. Vpowerd.h contains the following prototype for this service:


POWERRET
POWERFAR CDECL
_VPOWERD_Get_Mode(
	PDWORD Mode
        ); 

The single parameter passed to this function is a pointer to a DWORD that VPOWERD fills in with the system's power management mode, encoded as follows:

0:  APM mode
1:  ACPI mode 
You should call _VPOWERD_Get_Version before calling _VPOWERD_Get_Mode to make sure that VPOWERD is loaded.

Thirty-two bit Windows applications can also make use of this service via VPOWERD's DeviceIoControl interface, which the following code fragment demonstrates. Note that the third DeviceIoControl parameter, lpInBuffer, is a pointer to a pointer to a DWORD buffer that receives the power management mode. The fifth DeviceIoControl parameter, lpOutBuffer, points to a DWORD buffer that receives the return error status value from _VPOWERD_Get_Mode.


#define VPOWERD_IOCTL_GET_MODE 0x00000021<BR/>
HANDLE  hndl;
DWORD   dwPwrMode;
DWORD   dwRetVal;
DWORD   cbBytes_Ret;

dwPwrMode = (DWORD)&dwPwrMode;

hndl = CreateFile("\\\\.\\VPOWERD",GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hndl == INVALID_HANDLE_VALUE)
{
  printf("VPOWERD not loaded\n");
}
else
{
  if (!DeviceIoControl(hndl, VPOWERD_IOCTL_GET_MODE, &dwPwrMode, sizeof(dwPwrMode), &dwRetVal, sizeof(dwRetVal), &cbBytes_Ret, NULL))
  {
    printf("DeviceIoControl to VPOWERD failed\n");
  }
  else
  {
    printf("VPOWERD_GET_MODE return status (0=success): %lx\n",dwRetVal);
    printf("# of bytes returned: %lx\n",cbBytes_Ret);
    printf("Power Mode (0=APM, 1=ACPI): %lx\n",dwPwrMode);
  }
} 


REFERENCES

See the Windows 98 DDK for more information on VPOWERD and power management.

Additional query words:


Keywords          : kbDDK kbWin32s kbWinOS98 
Version           : Win98:
Platform          : Win98 
Issue type        : kbinfo 

Last Reviewed: August 2, 1999