윈도우 강제 Shut Down 시키기

Software/C++ Builder|2023. 6. 7. 17:15
반응형

void __fastcall Windows_ShutDown(void)
{
    HANDLE hToken;
    TOKEN_PRIVILEGES tp;
    LUID luid;
    OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &hToken);
    LookupPrivilegeValue(NULL, "SeShutdownPrivilege", &luid);
    tp.PrivilegeCount = 1 ;
    tp.Privileges[0].Luid = luid ;
    tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED ;
    AdjustTokenPrivileges(hToken, false, &tp, 0, NULL, NULL) ;
    ExitWindowsEx(EWX_SHUTDOWN, 0);
}

반응형

댓글()