Microsoft KB Archive/194939

{|
 * width="100%"|

HOWTO: Monitor System Power Events in VxDs

 * }

Q194939

-

The information in this article applies to:


 * Microsoft Win32 Device Driver Kit (DDK) Windows 95

-

SUMMARY
Monitoring system power events from a VxD involves using the _SHELL_HookSystemBroadcast service to install a callback procedure into the broadcast notification chain. WM_POWERBROADCAST messages are used in both APM and ACPI systems to notify applications and drivers of system power events. Use _SHELL_UnhookSystemBroadcast to remove a callback procedure from the broadcast notification chain. Dynamically loaded VxDs should use this service to remove any broadcast callbacks prior to unloading, such as during SYS_DYNAMIC_DEVICE_EXIT.

MORE INFORMATION
A WM_POWERBROADCAST message passes the following parameters:

dwPowerEvent = (DWORD) wParam;

dwData = (DWORD) lParam; Note that the following sample callback procedure uses the C calling convention:

  #include "pbt.h"

DWORD _cdecl Broadcast_Hook(DWORD Message,                              DWORD wParam,                               DWORD lParam,                               DWORD dwRefData) {

if (Message == WM_POWERBROADCAST) { Out_Debug_String("Power Message!\n"); }  }