Monitoring display power events on Windows XP

On Windows only the focused application receives display power events via the WM_SYSCOMMAND message (with wParam set to SC_MONITORPOWER , and lParam representing the new power state).

On Windows Vista and later, any application can be notified of display power events by calling the RegisterPowerSettingNotification function, using the GUID_SESSION_DISPLAY_STATUS GUID.

Is there a way to achieve the same result on Windows XP, at application level (ie not using code running at kernel mode)?


All you need to do is handle WM_SYSCOMMAND . Options I can think of:

  • Use SetWindowsHookEx for this (with WH_CBT ).

  • Inject a DLL into every process which hooks CreateProcess and injects itself into all future processes, essentially hooking the entire system. The aforementioned DLL will then subclass all windows in the current process, and you can handle WM_SYSMESSAGE from there.


  • 你不能只处理你的WindowProc中的消息WM_POWERBROADCAST,一旦收到,调用GetSystemPowerStatus?

    链接地址: http://www.djcxy.com/p/47478.html

    上一篇: 如何处理笔记本电脑上的关闭电源按钮

    下一篇: 监视Windows XP上的显示器电源事件