Sáb Oct 02, 2010 4:47 pm
Alternativa a "system(shutdown -s)"
- Código:
#include <windows.h>
int main()
{
HANDLE hToken;
TOKEN_PRIVILEGES tokpr;
if (OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
{
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tokpr.Privileges[0].Luid);
tokpr.PrivilegeCount = 1;
tokpr.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(AdjustTokenPrivileges(hToken, FALSE, &tokpr, 0, (PTOKEN_PRIVILEGES)NULL, 0))
{
ExitWindowsEx(EWX_SHUTDOWN|EWX_POWEROFF|EWX_FORCE,0);
}
}
}