HOWTO: Monitor System Power Events in VxDs

ID: Q194939

The information in this article applies to:

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");
       }
   }

REFERENCES

Windows 95 DDK: _SHELL_HookSystemBroadcast; _SHELL_UnhookSystemBroadcast

Win32 SDK: WM_POWERBROADCAST message parameters

Additional query words:

Keywords          : kbmm kbDDK kbWinOS95 
Issue type        : kbhowto

Last Reviewed: October 31, 1998