NOTE: supported on Vista+
This is a demo on monitoring the state of a laptop's lid. Notice how you can't make a laptop lock when you close the lid? Here's one solution:
Global Const $WM_POWERBROADCAST = 0x0218
; GUID_LIDSWITCH_STATE_CHANGE GUID
; 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3
Global Const $GUID_LIDSWITCH_STATE_CHANGE = DllStructCreate("byte[16]")
DllStructSetData($GUID_LIDSWITCH_STATE_CHANGE, 1, Binary("0x4D0F3EBA17B89440A2D1D56379E6A0F3"))
; cr