How in C # to determine whether the laptop lid is closed?
It is necessary that the program performs actions only with the lid closed.

    1 answer 1

    The great and mighty comes to the rescue:

    If you are a Lid Close Action changes. This is done by calling RegisterPowerSettingNotification (see for details). GUID_LIDCLOSE_ACTION. This is the wdm.h in the Platform SDK.

    Once registered, WM_POWERBROADCAST will be set to PBT_POWERSETTINGCHANGE . This is the time for the event. POWERBROADCAST_SETTING structure (see ) containing information about the setting.

    ( from here )