-
Get lid status in C/C++
Hi,
I am looking for a way to get lid status in Windows using C/C++. I want to do certain things when the laptop's lid is down so I am trying to find an interface to read its status.
Unfortunately I haven't found any way to do so. I have tried almost anything I have found on the web but nothing worked.
Any Idea is more than welcome.
Thank you in advance. :-)
-
Anything like that is going to be proprietary to the board used by the laptop.
-
O_o
You can't do this.
In every operating system I know of the user can configure "what happens", the ACPI power state, when you "close the lid" on a portable device. The device may "go to sleep", "hibernate", or "power off".
From a developer standpoint, "what happens" is simply not a realistic concern. You, as a developer, can either deal with the interruption or annoy your users when your application fails.
Some operating systems provide an API to allow certain applications to request a "wait period" to gracefully shutdown. Others at least provide a system notification event (`WM_POWERBROADCAST') to alert applications to the interruption. One way or the other, once the operating system "switches" to such a state, the CPU is "off limits".
It doesn't make any sense to allow a program to execute while in a "power saving" state like "sleep" and is simply impossible in a state like "power off".
Soma
-
I want to read the lid status in order to decide whether the laptop should sleep or remain powered on and do some other things. It is a special application and the default power management will be disabled (eg auto suspend).
For example under linux, hal/udev provides info about the lid status (in most cases). In some laptop you can even read it via /proc but I coulnd't found anything similar for windows.
How does windows know when the lid is down? I think that drivers should provide a "standard" interface to read the status.
-
Ah. So you don't want to know the "lid status" so much as you want to know when a "lid event" happens before the ACPI has a chance. That is a different story. It can be done, but since you've said "the default power management will be disabled" I have no intention of telling you how to do it.
No offense, I just don't trust you. The same code could be used to do a lot of naughty things.
Soma
-
thednick, you may have good intentions, but phantomotap has a point, so in accordance with the forum guidelines, I am closing this thread.