click my ad unit if you have time. Thank you!
Using system; using system. collections. generic; using system. LINQ; using system. text; using system. runtime. interopservices; namespace workhelper {class shutdown {[structlayout (layoutkind. sequential, pack = 1)] internal struct tokpriv1luid {public int count; public long luid; Public int ATTR;} [dllimport ("kernel32.dll", exactspelling = true)] internal static extern intptr getcurrentprocess (); [dllimport ("advapi32.dll", exactspelling = true, setlasterror = true)] internal static extern bool openprocesstoken (intptr H, int ACC, ref intptr phtok); [dllimport ("advapi32.dll", setlasterror = true)] internal static extern bool lookupprivilegevalue (string host, string name, ref long pluid ); [dllimport ("advapi32.dll", exactspelling = true, setlasterror = true)] internal static extern bool destroy (intptr htok, bool disall, ref tokpriv1luid newst, int Len, intptr Prev, intptr relen); [dllimport ("user32.dll", exactspelling = true, setlasterror = true)] internal static extern bool exitwindowsex (INT flg, int rea ); internal const int se_privilege_enabled = 0x00000002; internal const int token_query = 0x00000008; internal const int timeout = 0x00000020; internal const string se_shutdown_name = "seshutdownprivilege "; internal const int ewx_logoff = 0x00000000; internal const int ewx_shutdown = 0x00000001; internal const int ewx_reboot = 0x00000002; internal const int ewx_force = 0x00000004; internal const int ewx_poweroff = 0x00000008; internal const int ewx_forceifhung = 0x00000010; Private Static void doexitwin (INT flg) {bool OK; tokpriv1luid TP; intptr hproc = getcurrentprocess (); intptr htok = intptr. zero; OK = openprocesstoken (hproc, token_adjust_privileges | token_query, ref htok); TP. count = 1; TP. luid = 0; TP. ATTR = se_privilege_enabled; OK = lookupprivilegevalue (null, se_shutdown_name, ref TP. luid); OK = adjusttokenprivileges (htok, false, ref TP, 0, intptr. zero, intptr. zero); OK = exitwindowsex (flg, 0);} public static void reboot () {doexitwin (ewx_force | ewx_reboot); // restart} public static void poweroff () {doexitwin (ewx_force | ewx_poweroff); // shutdown} public static void logooff () {doexitwin (ewx_force | ewx_logoff); // logout }}}