Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3670
Number of posts: 9122

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Edit Report
Windows 95 shutdown function Posted by Chris Decker on 20 Apr 2000 at 8:27 PM
I know it is there, but I can't seem to remember the syntax or where to find a referance.


Edit Report
Re: Windows 95 shutdown function Posted by timtimtim on 21 Apr 2000 at 3:43 PM
<br>
Use ExitWindowsEx using <br>
EWX_SHUTDOWN || EWX_FORCE as the parameters.<br>
<br>
Timtimtim.<br>
<br>



Edit Report
Re: Windows 95 shutdown function Posted by Stoic Joker on 26 Apr 2000 at 5:12 PM
: I know it is there, but I can't seem to remember the syntax or where to find a referance.<br>
: <br>
<br>
Greeting's<br>
The Windows ShutDown code is one of my favorite toys. For Win95/98 only use<br>
<br>
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)<br>
{<br>
ExitWindowsEx(EWX_SHUTDOWN,0);<br>
return 0;<br>
}<br>
I dont like to force the shutdown right from zero if you want to include it as an option use<br>
<br>
if(!ExitWindowsEx(EWX_SHUTDOWN,0)<br>
{<br>
ExitWindowsEx(EWX_SHUTDOWN|EWX_FORCE,0);<br>
} <br>
<br>
If you want to ShutDown Win95/98/NT/2000<br>
use<br>
HANDLE hToken;<br>
TOKEN_PRIVILEGES tkp;<br>
WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)<br>
{<br>
if(!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken));<br>
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);<br>
tkp.PrivilegeCount = 1;<br>
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;<br>
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES)NULL, 0);<br>
if(!ExitWindowsEx(EWX_REBOOT, 0))<br>
{<br>
ExitWindowsEx(EWX_REBOOT|EWX_FORCE,0);<br>
}<br>
return 0;<br>
}<br>
<br>
also windows.h is the only include file you'll need for any of this<br>
<br>
<br>






 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.