Solved

Is WindowsExit(EWX_POWEROFF) bad fr your computer?

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 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

23 Experts available now in Live!

Get 1:1 Help Now