예제 #1
0
 public static void DoAutoShutdown(AutoShutdownAction action)
 {
     if (action == AutoShutdownAction.Quit)
     {
         Application.Exit();
     }
     else if (action == AutoShutdownAction.StandBy)
     {
         Application.SetSuspendState(PowerState.Suspend, false, false);
     }
     else if (action == AutoShutdownAction.Hibernate)
     {
         Application.SetSuspendState(PowerState.Hibernate, false, false);
     }
     else if (action == AutoShutdownAction.TurnOff)
     {
         Util.WTSShutdownSystem(IntPtr.Zero, 0x00000008 /* WTS_WSD_POWEROFF */);
     }
     else if (action == AutoShutdownAction.Restart)
     {
         Util.WTSShutdownSystem(IntPtr.Zero, 0x00000004 /* WTS_WSD_REBOOT */);
     }
     else if (action == AutoShutdownAction.LogOff)
     {
         Util.WTSLogoffSession(IntPtr.Zero, unchecked ((uint)-1), false);
     }
     else if (action == AutoShutdownAction.LockComputer)
     {
         Util.LockWorkStation();
     }
     else
     {
         Debug.Assert(false);
     }
 }
예제 #2
0
        public AutoShutdownPrompt(AutoShutdownAction action)
        {
            msecCount   = 0;
            this.action = action;
            prompt      = Util.translationList["000122"];

            if (action == AutoShutdownAction.None)
            {
                return;
            }

            InitializeComponent();

            string s = string.Format(prompt, "{0}", totalSec);

            if (action == AutoShutdownAction.Quit)
            {
                msgLabel.Text = String.Format(s, Util.translationList["000124"]);
            }
            else if (action == AutoShutdownAction.StandBy)
            {
                msgLabel.Text = String.Format(s, Util.translationList["000125"]);
            }
            else if (action == AutoShutdownAction.Hibernate)
            {
                msgLabel.Text = String.Format(s, Util.translationList["000126"]);
            }
            else if (action == AutoShutdownAction.TurnOff)
            {
                msgLabel.Text = String.Format(s, Util.translationList["000127"]);
            }
            else if (action == AutoShutdownAction.Restart)
            {
                msgLabel.Text = String.Format(s, Util.translationList["000128"]);
            }
            else if (action == AutoShutdownAction.LogOff)
            {
                msgLabel.Text = String.Format(s, Util.translationList["000129"]);
            }
            else if (action == AutoShutdownAction.LockComputer)
            {
                msgLabel.Text = String.Format(s, Util.translationList["000130"]);
            }
            else
            {
                Debug.Assert(false);
            }
        }