How to control the push of a power button?

I am working on a kiosk style application where I need to control the shutdown / reboot of a PC when I press the power button. Thanks to the post, I'm about 90% of the way there.

  • On the control panel, set the acpi power button to stop operation.
  • Listen to the WndProc WM_QUERYENDSESSION message
  • When the resulting problem is completely undocumented:

    [DllImport("user32.dll", SetLastError = true)] static extern int CancelShutdown(); 
  • Return from WndProc and raise my own window asking the user to shutdown / restart or Cancel and respond to their action.

Everything works well if I start / end the taskbar (I can issue abstracts as quickly as I want). Everything works well when I press the power button. On the next power button, press, although I see a minute or so of delay before I receive the WM_QUERYENDSESSION message.

Is there a parameter or registry entry about how often windows throw an ACPI event? I know that this is not hardware, because under Linux the same computer will fire an ACPI event as fast as I can click a button.

Thanks.

+7
source share
2 answers

Causing some benefits at work, I was able to answer this question directly in support of Microsoft. According to my third support engineer, I was essentially told that this is not possible at the application level. His belief was that calling undocumented CancelShutdown() “confuses” the power manager or acpi driver, which delays the WM_QUERYENDSESSION message. Because CancelShutdown() undocumented, MS is unwilling to explore further.

So how do you press the power buttons? You need to write a device driver, in particular, ACPI Filter Driver . We are studying it now.

+1
source

I don’t think it’s possible if you don’t talk to the equipment manufacturer or start the start button so that it does not send a signal to the hardware that processes it. You can only delay it, but even this will not give you a 100% guarantee, I think.

Windows 8.1 (possibly) will result in kiosk mode. Perhaps this is what you are looking for -)

0
source

All Articles