예제 #1
0
        //
        //combine calls into shared functions
        //
        internal static void ChangeSystemState(ExitWinCmd flags)
        {
            TokPriv1Luid tpl;

            IntPtr hdl = GetCurrentProcess();
            IntPtr tkn = IntPtr.Zero;

            //TOKEN_ADJUST_PRIVELEGES = 0x00000020
            //TOKEN_QUERY             = 0x00000008
            OpenProcessToken(hdl, (uint)32 | (uint)8, ref tkn);
            tpl.Count = 1;
            tpl.Luid  = 0;
            tpl.Attrb = 2; //SE_PRIVILEGE_ENABLED
            LookupPrivilegeValue(null, "SeShutdownPrivilege", ref tpl.Luid);
            AdjustTokenPrivileges(tkn, false, ref tpl, 0, IntPtr.Zero, IntPtr.Zero);
            //SHTDN_REASON_MAJOR_OTHER = 0x00000000
            //SHTDN_REASON_MINOR_OTHER = 0x00000000
            ExitWindowsEx(flags, (uint)0 | (uint)0);
        }
예제 #2
0
 internal static extern bool ExitWindowsEx(ExitWinCmd uFlags, uint dwReason);