Red de conocimiento informático - Conocimiento del nombre de dominio - ¿Cómo utilizar la codificación en lenguaje C para que la computadora se apague automáticamente?

¿Cómo utilizar la codificación en lenguaje C para que la computadora se apague automáticamente?

# incluir ltwindows.h gt

# incluir ltcstdio gt

int main()

{

TOKEN _ PRIVILEGES tkp

Manejo de hToken

if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRVILEGES | TOKEN_QUERY, amphToken))

{

MessageBox(NULL, "OpenProcessToken ¡falló!", NULL, 0);

}

LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, amptkp.Permissions[0].luid);

tkp. PrivilegeCount = 1;

tkp. Permisos[0]. Atributos = SE_PRIVILEGES_ENABLED

AdjustTokenPrivileges(hToken, FALSE, amptkp, 0, (PTOKEN_PRIVILEGES) NULL, 0);

if (GetLastError()!=Error_Success)

{

MessageBox( NULL, "¡Falló la activación de AdjustTokenPrivileges!", NULL, 0);

}

int f resultado = iniciarsistemasistema apagado(nulo, "Debido a una excepción del sistema, WINDOWS no puede continuar ejecutándose, WINDOWS se está cerrando...", 100, false, false);

If (!fResult)

{

MessageBox(NULL, "Error al iniciar el cierre del sistema.", NULL, 0);

}

tkp. Permisos[0]. propiedades = 0;

AdjustTokenPrivileges(hToken, FALSE, amptkp, 0, (PTOKEN_PRIVILEGES) NULL, 0);

if (GetLastError()!=Error_Success)

{

MessageBox(NULL, "Error al deshabilitar AdjustTokenPrivileges.", NULL, 0

}

//ExitWindowsEx(EWX_SHUTDOWN, 0); ¿Por qué no lo apagas?

Devuelve 0;

}