Well, ExitWindows() may be a strike out, but I have found a workaround...
The following site on MSDN utilizes a function called InitiateSystemShutdown().
http://msdn.microsoft.com/library/de...tdown_04ry.asp
Here is some samplecode I ran that shut down my system quite nicely....
Code:
BOOL fResult;
HANDLE hToken; // handle to process token
TOKEN_PRIVILEGES tkp; // pointer to token structure
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// Get the current process token handle so we can get shutdown
// privilege.
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
MessageBox(NULL,NULL,"OpenProcessToken failed.", MB_OK | MB_ICONINFORMATION);
// Get the LUID for 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 shutdown privilege for this process.
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES) NULL, 0);
// Cannot test the return value of AdjustTokenPrivileges.
if (GetLastError() != ERROR_SUCCESS)
MessageBox(NULL,NULL,"AdjustTokenPrivileges enable failed.",MB_OK | MB_ICONINFORMATION);
// Display the shutdown dialog box and start the time-out countdown.
fResult = InitiateSystemShutdown(
NULL, // shut down local computer
"Click on the main window and press the Escape key to cancel shutdown.", // message to user
3, // time-out period
TRUE, // ask user to close apps
TRUE); // reboot after shutdown
if (!fResult)
{
MessageBox(NULL,NULL,"InitiateSystemShutdown failed.",MB_OK | MB_ICONINFORMATION);
}
// Disable shutdown privilege.
tkp.Privileges[0].Attributes = 0;
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES) NULL, 0);
if (GetLastError() != ERROR_SUCCESS)
{
MessageBox(NULL,NULL,"AdjustTokenPrivileges disable failed.",MB_OK | MB_ICONINFORMATION);
}
return 0;
}
You can set the timer, and the code can be altered to avert shutdown within the timer period, the code for that is included on the website...
Maybe this will finally help the original poster