I\'m writing a C# app (specifically for laptops) and I want to be aware of the state of the lid, i.e. when is it open and when is it closed.
I\'ve already used pInvoke a
So after a long search led by @Llwyd's answer, I found a solution.
I noticed that when the lid is closed the device is removed from the device manager, so the solution is to check whether it is there or not.
The code behind it is a bit massive to upload here so I won't, but the following was need:
1) Identify Internal screen's name\ID with WmiMonitorConnectionParams
and VideoOutputTechnology
and state (DISPLAY_DEVICE_ATTACHED
and/or DISPLAY_DEVICE_ACTIVE
)
2) Once I know the device's name/ID I can easily look it up by enumerating System.Windows.Forms.Screen.AllScreens (or save the value from the DISPLAY_DEVICE_ATTACHED)