Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Shutdown...?

This topic is 5190 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
This question was already posed some times ago: I just say: ExitWindowsEx().... Look it up in the MSDN , it''S quite easy!

Share this post


Link to post
Share on other sites
Darn beat me to it!

The Win32 API function: " ExitWindowsEx", although be sure your application has the privilege before invoking it.

[edited by - Xiachunyi on March 6, 2004 11:33:51 AM]

Share this post


Link to post
Share on other sites
Nothing happens here''s my code:
//---------------------------------------------------------------------------

#include <iostream.h>
#include <windows.h>
#include <windowsx.h>

int main(void)
{
ExitWindowsEx(EWX_SHUTDOWN, NULL);
return(0);
}

Share this post


Link to post
Share on other sites
To shut down or restart the system, the calling process must use the AdjustTokenPrivileges function to enable the SE_SHUTDOWN_NAME privilege.

[edited by - Lantz on March 6, 2004 12:06:24 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by PlayGGY
I would doubt a console application could call it, anyways.

Actually that shouldn''t make any difference, windows does not differ between console apps and regular ones.

Share this post


Link to post
Share on other sites
You could try something like this (i havent tried it):

HANDLE token;
OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token );

TOKEN_PRIVILEGES p;
p.PrivilegeCount = 1;
p.Privileges[0].Luid = 0;
p.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( token, false, &p, 0, NULL, 0 );

CloseHandle( token );

Share this post


Link to post
Share on other sites
Nothing happpens again. Thsi is th ecode I have so far:

HANDLE token;
OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token );
TOKEN_PRIVILEGES p;
p.PrivilegeCount = 1;
p.Privileges[0].Luid;
p.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( token, false, &p, 0, NULL, 0 );
CloseHandle( token );
ExitWindowsEx(EWX_POWEROFF, NULL);

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!