Click here to Skip to main content
14,765,715 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: access violation at 0x00000000 Pin
IsaacLitingjun30-Jan-05 16:24
MemberIsaacLitingjun30-Jan-05 16:24 
GeneralRe: access violation at 0x00000000 Pin
PJ Arends30-Jan-05 17:09
professionalPJ Arends30-Jan-05 17:09 
GeneralRe: access violation at 0x00000000 Pin
IsaacLitingjun30-Jan-05 18:22
MemberIsaacLitingjun30-Jan-05 18:22 
Generaltext file to Word document Pin
yannah30-Jan-05 15:56
Memberyannah30-Jan-05 15:56 
Generalget the system driver Pin
masmstudio30-Jan-05 15:40
Membermasmstudio30-Jan-05 15:40 
GeneralPowering down Win98 system Pin
Still learning how to code30-Jan-05 12:05
MemberStill learning how to code30-Jan-05 12:05 
GeneralRe: Powering down Win98 system Pin
PJ Arends30-Jan-05 12:32
professionalPJ Arends30-Jan-05 12:32 
GeneralRe: Powering down Win98 system Pin
Still learning how to code31-Jan-05 9:29
MemberStill learning how to code31-Jan-05 9:29 
I tried to use the sample code given in MSDN for shutting down the system using ExitWindowsEx(). (I've reproduced it below for reference):-

BOOL MySystemShutdown()
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;

// Get a token for this process.

if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return( FALSE );

// 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,
(PTOKEN_PRIVILEGES)NULL, 0);

if (GetLastError() != ERROR_SUCCESS)
return FALSE;

// Shut down the system and force all applications to close.

if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0))
return FALSE;

return TRUE;
}


It worked fine on my Win2000 Pro system but not on the Win98 machine (for which I actually need it !). It fails on the

OpenProcessToken() function and when I call GetLastError() in response, it returns a value of 120 ("The function is not

supported on this system")

How should I be using ExitWindowsEx on Win98 ?? (or is there a better way to do it ?)
Thanks for any help !

Doug
GeneralRe: Powering down Win98 system Pin
PJ Arends31-Jan-05 10:21
professionalPJ Arends31-Jan-05 10:21 
GeneralRe: Powering down Win98 system Pin
Still learning how to code31-Jan-05 11:31
MemberStill learning how to code31-Jan-05 11:31 
GeneralRe: Powering down Win98 system Pin
PJ Arends31-Jan-05 11:45
professionalPJ Arends31-Jan-05 11:45 
GeneralRe: Powering down Win98 system Pin
Still learning how to code31-Jan-05 12:31
MemberStill learning how to code31-Jan-05 12:31 
GeneralCalling th OSK (ON-Screen Keyboard) Pin
Alex Evans30-Jan-05 10:43
MemberAlex Evans30-Jan-05 10:43 
GeneralAlgorithm and necessary code Pin
joy00730-Jan-05 6:57
Memberjoy00730-Jan-05 6:57 
QuestionHow to Enable at runtime Pin
joy00730-Jan-05 6:40
Memberjoy00730-Jan-05 6:40 
AnswerRe: How to Enable at runtime Pin
Bob Ciora30-Jan-05 7:15
MemberBob Ciora30-Jan-05 7:15 
AnswerRe: How to Enable at runtime Pin
Ravi Bhavnani30-Jan-05 7:17
professionalRavi Bhavnani30-Jan-05 7:17 
GeneralCArray can't add Pin
jw8130-Jan-05 6:31
Memberjw8130-Jan-05 6:31 
GeneralRe: CArray can't add Pin
Bob Ciora30-Jan-05 7:09
MemberBob Ciora30-Jan-05 7:09 
GeneralRe: CArray can't add Pin
jw8130-Jan-05 7:50
Memberjw8130-Jan-05 7:50 
GeneralRe: CArray can't add Pin
Bob Ciora30-Jan-05 7:54
MemberBob Ciora30-Jan-05 7:54 
GeneralRe: CArray can't add Pin
jw8130-Jan-05 7:57
Memberjw8130-Jan-05 7:57 
GeneralRe: CArray can't add Pin
Bob Ciora30-Jan-05 8:02
MemberBob Ciora30-Jan-05 8:02 
GeneralRe: CArray can't add Pin
jw8130-Jan-05 20:03
Memberjw8130-Jan-05 20:03 
Questionwhy a COM can not be deleted? Pin
includeh1030-Jan-05 6:15
Memberincludeh1030-Jan-05 6:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.