Shutdown...?

Started by
10 comments, last by sathenzar 20 years, 1 month ago
Hey, does anyone know the command to shutpdwn your computer with VC++ 6.0? Thanks
Advertisement
This question was already posed some times ago: I just say: ExitWindowsEx().... Look it up in the MSDN , it''S quite easy!
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]
Nothing happens here''s my code:
//---------------------------------------------------------------------------#include <iostream.h>#include <windows.h>#include <windowsx.h>int main(void){	ExitWindowsEx(EWX_SHUTDOWN, NULL);	return(0);}
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]
I would doubt a console application could call it, anyways.
And the rockets' red glare, the bombs bursting in air,gave proof through the fight that our flag was still there.Oh say, does that star-spangled banner yet waveover the land of the free and the home of the brave?
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.
How would this function work? I''m looking and I don''t knwo how to set it up
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 );
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);

This topic is closed to new replies.

Advertisement