Click here to Skip to main content
15,888,321 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help native C++ and .net Pin
ThatsAlok6-May-09 1:16
ThatsAlok6-May-09 1:16 
GeneralRe: Help native C++ and .net Pin
ashish8patil6-May-09 3:14
ashish8patil6-May-09 3:14 
GeneralRe: Help native C++ and .net Pin
ashish8patil6-May-09 19:03
ashish8patil6-May-09 19:03 
QuestionHow to abort forcefully shutdown, reastart or logoff Pin
Abhijit A5-May-09 20:14
Abhijit A5-May-09 20:14 
AnswerRe: How to abort forcefully shutdown, reastart or logoff Pin
«_Superman_»5-May-09 20:24
professional«_Superman_»5-May-09 20:24 
GeneralRe: How to abort forcefully shutdown, reastart or logoff Pin
Abhijit A5-May-09 21:01
Abhijit A5-May-09 21:01 
GeneralRe: How to abort forcefully shutdown, reastart or logoff [modified] Pin
enhzflep5-May-09 21:19
enhzflep5-May-09 21:19 
AnswerRe: How to abort forcefully shutdown, reastart or logoff Pin
enhzflep5-May-09 21:04
enhzflep5-May-09 21:04 
bool shutDownWindows()
{
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);

// Cannot test the return value of AdjustTokenPrivileges.
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;
}


bool standbyWindows()
{
        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);

// Cannot test the return value of AdjustTokenPrivileges.
        if (GetLastError() != ERROR_SUCCESS)
            return false;



        if (!SetSuspendState(false, false, false))
            return false;

        return true;
}

GeneralRe: How to abort forcefully shutdown, reastart or logoff Pin
Abhijit A5-May-09 21:17
Abhijit A5-May-09 21:17 
AnswerRe: How to abort forcefully shutdown, reastart or logoff Pin
Stuart Dootson6-May-09 2:05
professionalStuart Dootson6-May-09 2:05 
GeneralRe: How to abort forcefully shutdown, reastart or logoff Pin
David Crow6-May-09 3:11
David Crow6-May-09 3:11 
GeneralRe: How to abort forcefully shutdown, reastart or logoff Pin
Stuart Dootson6-May-09 3:21
professionalStuart Dootson6-May-09 3:21 
QuestionMFC application has encountered a problem and need to close Pin
ganesh.dp5-May-09 20:07
ganesh.dp5-May-09 20:07 
AnswerRe: MFC application has encountered a problem and need to close Pin
Cedric Moonen5-May-09 20:29
Cedric Moonen5-May-09 20:29 
AnswerRe: MFC application has encountered a problem and need to close Pin
_AnsHUMAN_ 5-May-09 21:38
_AnsHUMAN_ 5-May-09 21:38 
AnswerRe: MFC application has encountered a problem and need to close Pin
ThatsAlok5-May-09 23:20
ThatsAlok5-May-09 23:20 
AnswerRe: MFC application has encountered a problem and need to close Pin
Hamid_RT5-May-09 23:28
Hamid_RT5-May-09 23:28 
GeneralRe: MFC application has encountered a problem and need to close Pin
ganesh.dp5-May-09 23:36
ganesh.dp5-May-09 23:36 
AnswerRe: MFC application has encountered a problem and need to close Pin
David Crow6-May-09 3:14
David Crow6-May-09 3:14 
QuestionPartial Specialization of Templated Class Member Function Pin
Jmuulian5-May-09 19:26
Jmuulian5-May-09 19:26 
AnswerRe: Partial Specialization of Templated Class Member Function Pin
«_Superman_»5-May-09 20:04
professional«_Superman_»5-May-09 20:04 
AnswerRe: Partial Specialization of Templated Class Member Function Pin
Stuart Dootson6-May-09 2:14
professionalStuart Dootson6-May-09 2:14 
QuestionOpening a Visual Studio .NET application in Visual Studio C++ Pin
SivaGK5-May-09 19:26
SivaGK5-May-09 19:26 
AnswerRe: Opening a Visual Studio .NET application in Visual Studio C++ Pin
«_Superman_»5-May-09 19:29
professional«_Superman_»5-May-09 19:29 
AnswerRe: Opening a Visual Studio .NET application in Visual Studio C++ Pin
_AnsHUMAN_ 5-May-09 19:47
_AnsHUMAN_ 5-May-09 19:47 

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.