Windows NT is a bit different to Win 98
This code should do the trick for you.
#include "stdafx.h"
#include "WinUtil.h"
#include "WinUtilDlg.h"
#include "WINUSER.H"
void shutdow()
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
// get the token for this process
if(!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken));
// get the LUID for the shutdown privilegde
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
//get the shutdown priviledge
AdjustTokenPrivileges(hToken, FALSE, &tkp,0,(PTOKEN_PRIVILEGES)NULL, 0);
ExitWindowsEx (EWX_SHUTDOWN | EWX_FORCE,0);
}
"Roberto Bozzolo" wrote in message
news:50650
00000050000005A1F0000-984882144000@quiq.com...
> According to Windows SDK you should use
> ExitWindowsEx(EWX_FORCE, 0);
> Look at the reference for this function for a detailed description of
> the first parameter (for example you could simply log your user
> off...).
> You must #include in your project.
> I used it in Win95 and Win98 and it works well. I hadn't tested it in
> NT, but it's simple to try...
>
> Hope this helps.
> Roberto