Ejemplo n.º 1
0
        void RestartOrShotDown(WinAPIClass5.ShutdownType type)
        {
            WinAPIClass5.TokPriv1Luid tp;
            IntPtr hproc  = WinAPIClass5.GetCurrentProcess();
            IntPtr hToken = IntPtr.Zero;

            WinAPIClass5.OpenProcessToken(hproc, WinAPIClass5.TOKEN_ADJUST_PRIVILEGES | WinAPIClass5.TOKEN_QUERY, ref hToken);
            tp.Count = 1;
            tp.Luid  = 0;
            tp.Attr  = WinAPIClass5.SE_PRIVILEGE_ENABLED;
            WinAPIClass5.LookupPrivilegeValue(null, WinAPIClass5.SE_SHUTDOWN_NAME, ref tp.Luid);
            WinAPIClass5.AdjustTokenPrivileges(hToken, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
            WinAPIClass5.ExitWindowsEx((uint)type, "Win Api test");
        }
Ejemplo n.º 2
0
 private void btnUserOut_Click(object sender, EventArgs e)
 {
     WinAPIClass5.ExitWindowsEx((uint)WinAPIClass5.ShutdownType.LogOf, "Win Api test");
 }