Hola Fabio:2). Para apagar un equipo con Windows NT/2000/XP:
//--- Obtenemos el permiso necesario del sistema
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
throw Exception("Error :: OpenProcessToken");
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
if (GetLastError() != ERROR_SUCCESS)
throw Exception("Error :: AdjustTokenPrivileges");
//--- Apagamos
if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0))
throw Exception("ExitWindowsEx");
NOTA: En Windows 2000 funciona sin problemas, en Windows NT puede que no funcione sin alguno de los service packs, pero bueno, si se apaga cuando le mandamos a apagarse desde el menú esto también debería funcionar.
Saludos.
_Leo