Sorry, I cut and pasted that out of some code in my personal shared library, but missed one line. The declaration of hToken is;
HANDLE hToken; Have fun. You can change the EWX_POWEROFF to various things if you just want to log off, shutdown or even reboot. I have had trouble with various other ways of doing this not being portable across various OS's, but I have tested this on everything except Win95. Rob Prouse http://www.tourofdutymod.com At 04:56 PM 14/04/2002 +0200, you wrote: >This is a multi-part message in MIME format. >-- >[ Picked text/plain from multipart/alternative ] >Thx for the tip (and thx to Botman too). > >I've tried your 2 solutions. The one which is the more appopriate in my >case is the one from you, Commando (I like the EWX_POWEROFF flag :) ) ! > >The only trouble I ran into is that I don't know what should hToken be... >I took a look at MSDN... Now, I declare it as PHANDLE, but it must be an >other thing to do like : "hToken = ...();". > >Thx in advance :) > > - Cortex : mapper & coder www.hlalbator.fr.st > > ----- Original Message ----- > From: Commando > To: [EMAIL PROTECTED] > Sent: Saturday, April 13, 2002 2:26 PM > Subject: Re: [hlcoders] little app > > > This should work on all systems; > > // Get a token for this process. > if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | > TOKEN_QUERY, &hToken)) > { > TOKEN_PRIVILEGES tkp; > > // Get the LUID for the shutdown privilege. > LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, > &tkp.Privileges[0].Luid); > > tkp.PrivilegeCount = 1; // one privilege to set > tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; > > // Get the shutdown privilege for this process. > AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, 0); > > CloseHandle(hToken); > } > > // Shut down the system and force all applications to close. > ExitWindowsEx(EWX_POWEROFF, 0); > > > At 09:52 AM 13/04/2002 +0200, you wrote: > >This is a multi-part message in MIME format. > >-- > >[ Picked text/plain from multipart/alternative ] > >Hello, > > > >I've downloaded the new Hammer 4.3 but there's 2 features I excepted I > >haven't seen :( > > > >The first is to be able to print the map draft... But I can do without > it :) > > > >The second thing is a "Shut down after succesful compilation" checkbox... > >It'd be very useful. > > > >Now comes the real code question :D I found a way to get around this > >without a new version... The principle is to make a little Console > >Application which could be run after the compil tools (in the Run window) > >and which shuts down the PC. But I don't know how to shut down a PC in > >C++... Does anyone know a solution ? > > > > - Cortex : mapper & coder www.hlalbator.fr.st > >-- > > > > > >_______________________________________________ > >To unsubscribe, edit your list preferences, or view the list archives, > >please visit: > >http://list.valvesoftware.com/mailman/listinfo/hlcoders > > _______________________________________________ > To unsubscribe, edit your list preferences, or view the list archives, > please visit: > http://list.valvesoftware.com/mailman/listinfo/hlcoders > > >-- > > >_______________________________________________ >To unsubscribe, edit your list preferences, or view the list archives, >please visit: >http://list.valvesoftware.com/mailman/listinfo/hlcoders _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders