|
-
Dec 5th, 2011, 11:53 PM
#4
Re: Laptop "Lid Close Test"
A bit more time Googling led me to this MSDN forum thread:
http://social.msdn.microsoft.com/For...-016b57211b3a/
In short: You need to call RegisterPowerSettingNotification to receive the power state messages. Pass a window handle for the first parameter and DEVICE_NOTIFY_WINDOW_HANDLE (0) for the third. The second parameter is a GUID structure (use System.GUID in .NET) representing GUID_LIDSWITCH_STATE_CHANGE:
0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3
The type of message that you need to trap is WM_POWERBROADCAST (0x218).
The event type (wParam) is PBT_POWERSETTINGCHANGE (0x8013). Use an overriden WndProc to trap the message.
Here is some more information:
Trapping the WM_POWERBROADCAST Window Message
This all requires Windows Vista or later, by the way.
Last edited by penagate; Dec 7th, 2011 at 06:18 PM.
Reason: Several errors...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|