I'm writing a C++ app, and I want to get the current lid state of the laptop.
Note: not catch an event of the lid state changing, but once main() is executed, get the current lid state.
Asked
Active
Viewed 96 times
1
Remy Lebeau
- 505,946
- 29
- 409
- 696
Hrach Martirosyan
- 11
- 2
-
1FYI: [SO: Get current laptop lid state](https://stackoverflow.com/q/26869987/7478597) – Scheff's Cat Nov 04 '21 at 18:32
1 Answers
-4
The implementation how to get lid state by C#. https://github.com/rowandh/lidstatusservice
I think that shouldn't be problematic to translate the code to C++.
Narek Aydinyan
- 173
- 7
-
1That solution is not querying the current lid status. It is launching a background service that calls `RegisterPowerSettingNotification()` to receive `PBT_POWERSETTINGCHANGE` notifications looking for `GUID_LIDSWITCH_STATE_CHANGE` events: "*The state of the lid has changed (open or closed).*" The OP stated they did not want to handle events. – Remy Lebeau Nov 04 '21 at 23:00