Apagado-Shutdown Function(Windows)

Iniciado por Jhonjhon_123, Febrero 23, 2010, 07:32:54 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Febrero 23, 2010, 07:32:54 PM Ultima modificación: Febrero 08, 2014, 05:43:44 PM por Expermicid
Alternativa a "system(shutdown -s)"

Código: c
#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);
      }
      }
      }


Saludos!

Autor: P4|3L0
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta

Agosto 10, 2012, 08:46:07 AM #1 Ultima modificación: Marzo 31, 2016, 05:46:27 AM por P4|3L0
Jajaja grandisimo código!! (Que va creo que mi sobrino reccien nacido puede hacerlo)

:o :o :o

Se ve interesante....no imaginaba la existencua de este codigo.,

... Saludos --->

excelente me servira para ver como manejar los permisos en windows

salu2