Results 1 to 17 of 17

Thread: [RESOLVED] Laptop "Lid Close Test"

Threaded View

  1. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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
  •  



Click Here to Expand Forum to Full Width