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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shutting the system down

Status
Not open for further replies.

Baal80

Programmer
Aug 14, 2004
14
PL
Hello!

I have a following problem - I want to shut the system down from within my application. I'm using the following code:

[first, if Windows version is WinXP or Win2000 or Win2003 I set the necessary privilege (SE_SHUTDOWN_NAME) - this WORKS, I'm sure about this part]

and then:

unsingned long a;
ExitWindowsEx(EWX_POWEROFF+EWX_FORCEIFHUNG,a);

Everything works fine on XP, 2000 and 2003. But:
- on Windows98SE the system just logs off and waits for the user to log on,
- on Windows NT4.0 with SP5 the system RESTARTS (doesn't shut down).

Can you tell me what am I doing wrong?
Or maybe these systems just don't support the "power-off feature" as described in Builder's Help?

Thanks in advance guys for your help.
 
Have you looked at
James P. Cottingham
-----------------------------------------
To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.
 
Unfortunately yes. I have the necessary privileges. This behaviour is strange to me. I managed to use another function to shutdown Win98SE (my app determines the Windows version) - "RUNDLL.EXE user.exe,exitwindows" - called by ShellExecute. Well, shutting down NT still causes a problem :(
 
I don't know if these sites will help or not. Here is some source code for Delphi:

If you want a third party program that your program can call, you can use:

Finally, there is documentation for Native API (a hidden API) at:

James P. Cottingham
-----------------------------------------
To determine how long it will take to write and debug a program, take your best estimate, multiply that by two, add one, and convert to the next higher units.
 
Well... I found a *very* interesting site - I reprogrammed functions to behave differently depending on the OS version (95/98+Me/2k+XP, NT is not supported) and the only thing I want to do know is to check if that works... As I have XP system, XP shutdown works fine for me, but what about 95/98/Me/2000... Does anybody have these systems nowadays? :(
 
Does anybody have these systems nowadays?"

you seem to think everybody ran off the cliff like good little lemurs following microsoft and XP.

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top