Solved

Is WindowsExit(EWX_POWEROFF) bad fr your computer?

Posted on 2004-08-18
3
798 Views
Last Modified: 2010-08-05
I have 2 buttons that execute these 2 lines of code
1:  WindowsExit(EWX_POWEROFF)
2. WindowsExit(EWX_REBOOT)
can these do any harm to your computer if used by themself to shut it down or restart?

thanks
Myles :)
0
Comment
Question by:myleseven2
3 Comments
 
LVL 3

Assisted Solution

by:Tyrsis
Tyrsis earned 25 total points
ID: 11835378
Are you talking about the ExitWindows() win32 API function?

Either way, it can't get any more danagerous then hitting your power button on your computer, or the reset button.  And usually when it's done pragmatically, it's even more safe.  You really shouldn't have any fear of doing these functions.  It was only long long long ago when turning off your computer could cause harm.  With today's computers it's a nonissue.

Tyrsis

0
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 25 total points
ID: 11840004
These functions can do harm to the data on your computer, but not to your computer itself...
First of all, computers don't just power off just like that. Hitting the poweswitch is not the same anymore as pulling the power plug and thus cutting off power. When you hit the power-off button, several computerparts will get enough power to finish whatever task needs to be done and then get into a safemode. Which basically means that harddisks will move the reader head to a track of the disk that cannot be damaged. (Which in the DOS time you had to do with the command PARK.EXE) Modern disks will always try to auto-park themselves if the power is disconnected.
And other hardware parts? Well, most are non-mechanical, no moving parts. The fan will stop fanning but that should not be a real problem since the processor won't continue to heat up anymore.

No, your hardware is reasonable safe...

However, for software, things are a bit different. Documents might not be saved, databases might not be updated, emails might not be sent, all because the power is disconnected. You could be working on a very important project and then the system resets while you haven't changed your modifications yet. I almost punched the nose of my previous system administrator once since he decided to remotely install a new Microsoft patch that needed a restart while I was running a long task that wasn't supposed to be stopped. The patch needed a reboot so I got a message (NET SEND stuff) on my system that I had 5 minutes to close all documents or else they would be lost. And my project was already running for an hour and had to stay running for another two hours... (It was a "quick" convertion of a very large database.)
Fortunately, in 5 minutes I did manage to get him and tell him to cancel that reboot or else his nose would be cancelled. Considering the circumstances he was willing to cancel the reboot.

Always be careful when planning a reboot/shutdown for other users. They could lose valuable time and data. But nothing more.
0
 

Author Comment

by:myleseven2
ID: 11846847
THat is great thanks guys, I will split the points between you both

Myles
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question