Solved

Is WindowsExit(EWX_POWEROFF) bad fr your computer?

Posted on 2004-08-18
3
796 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now