working with win. API: Shutting down

band-aid

Baseband Member
Messages
53
ok i'm just learning C++ and am trying to figure out how to shutdown a windows machine using API calls.

Code:
#include <windows.h>


int main(){
using namespace std;

BOOL WINAPI ExitWindowsEx(
  UINT EWX_SHUTDOWN | EWX_FORCEIFHUNG,
  DWORD SHTDN_REASON_MAJOR_OTHER
);

return 0;
}

on line 11 I am getting the compiler error on line 11

expected `,' or `...' before numeric constant

I've looked at it for a while and quite frankly I'm confused. What little knowledge I have on the subject has come from microsoft msdn.
 
Hmmm.... my documentation shows that there should be a different constant for it. Check out the code snippet below and see if that helps or hurts you.
And for good measure, you'd probably better convert the int main() thing into the more appropriate Winmain structure, too.

Code:
// My docs say that it isn't EWX_FORCEIFHUNG, just EWX_FORCE.
// And IMHO, it never hurts to group ops within a prototype call.  
// So I'd add some parentheses to the parameters to be OR'ed.
BOOL WINAPI ExitWindowsEx(
  UINT (EWX_SHUTDOWN | EWX_FORCE),
  DWORD SHTDN_REASON_MAJOR_OTHER
);

I hope this will help you out. Try it and see, but it could do you no good either. Constants in headers rarely change, but when they do they can have nasty effects, so proceed with all due caution!

You might just want to schlep on over to http://www.winprog.org/tutorial/ and read up on Win32 basics from the ground up. I hope some of this helps get you on your way.
 
Back
Top Bottom