Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

capture closing computer 1

Status
Not open for further replies.

GCTIberica

Programmer
Jun 20, 2003
30
ES
Hi

Does anyone know anything about closing a computer using the off switch (not closing the programs) - how I can capture this with code?

I need code that captures when a computer is switched off

thanks
 
Hi

Unfortunately this doesn´t work when I power off the computer

I don´t think anything can capture this...
 
When you say 'power off the computer', if you're talking about the same thing as pulling the plug out the back then no - there's no way to capture this.

The second best option to figure out if this happens is to do something once the power has come back on. It's fairly easy for a program to determine if it never went through it's OnClose routine.

The best option to track this is to install a UPS. UPS's come with either a serial cable or USB connection that allows the UPS to communicate to Windows or the UPS software that it has gone on to battery. I imagine it is possible to use the UPS DLLs to have your program notified that the power has failed. Your program could then do whatever, then shutdown the computer.

You can also tell Windows what to do when the Power button is pressed (ATX and ACPI only). Windows XP by default sets itself up to run it's shutdown routine when the power button is pressed. Windows 98 doesn't, but can be told to do so - you may have to install the ACPI drivers for this to work though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top