yateesh
asked on
To shut down the machine
i want to shut down, log off, and restart the machine(running on windows) using the functions which i can implement inVC++
(iam able to only log off using ExitWindowsEx function)
plz help in these pts
yateesh
(iam able to only log off using ExitWindowsEx function)
plz help in these pts
yateesh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
BOOL bOpenProcessTokenGood;
bOpenProcessTokenGood = OpenProcessToken(GetCurren tProcess() , (TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY), &hToken );
if( !bOpenProcessTokenGood )
{
return;
}
//************************ ********** ********** ********** ********** **
//* Get the LUID for the shutdown privilege. *
//************************ ********** ********** ********** ********** **
LookupPrivilegeValue( NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid );
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attribut es = SE_PRIVILEGE_ENABLED;
//************************ ********** ********** ********** ********** **
// Set the shutdown privilege for this process. *
//************************ ********** ********** ********** ********** **
AdjustTokenPrivileges(hTok en, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
ExitWindowsEx( EWX_REBOOT, NULL );
TOKEN_PRIVILEGES tkp;
BOOL bOpenProcessTokenGood;
bOpenProcessTokenGood = OpenProcessToken(GetCurren
if( !bOpenProcessTokenGood )
{
return;
}
//************************
//* Get the LUID for the shutdown privilege. *
//************************
LookupPrivilegeValue( NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid );
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attribut
//************************
// Set the shutdown privilege for this process. *
//************************
AdjustTokenPrivileges(hTok
ExitWindowsEx( EWX_REBOOT, NULL );
jrocnuck,
It seems you've been participating here on EE long enough to be aware of the rules...
It seems you've been participating here on EE long enough to be aware of the rules...
which rule are you refering to?
or rules..
were you aware that using terms like "simipleminded" is not really appropriate according to the rules?
Note that I said the APPROACH is simpleminded. I did NOT indicate that the user was. Take it up with the moderators.
same back at ya jack...
The term simpleminded should never be used period, it is arrogant and the wrong choice of words. If you cared anything about the real reason this site exists, you wouldn't use words like that and say the kinds of things I've seen you say in other posts.
This site is about helping people, not belittling them or their methods or approaches and not about boosting your ego by appearing to be a genius.
The term simpleminded should never be used period, it is arrogant and the wrong choice of words. If you cared anything about the real reason this site exists, you wouldn't use words like that and say the kinds of things I've seen you say in other posts.
This site is about helping people, not belittling them or their methods or approaches and not about boosting your ego by appearing to be a genius.
return FALSE;