1private void DoEvent()
2 {
3 Process[] arrProc = Process.GetProcesses();
4 foreach ( Process childProc in arrProc)
5 {
6 System.IntPtr hWnd = childProc.MainWindowHandle;
7 if (IsIconic(hWnd))
8 {
9 ShowWindowAsync(hWnd, SW_RESTORE);
10 SetForegroundWindow(hWnd);
11 if (!(childProc.MainWindowTitle.Equals(this.Text)))
12 {
13 childProc.CloseMainWindow();
14 childProc.Kill();
15 childProc.WaitForExit();
16 }
17 }
18 }
19 switch (cbEvent.SelectedText)
20 {
21 case "Shutdown":
22 WindowsController.ExitWindows(RestartOptions.ShutDown, false);
23 break;
24 case "Restart":
25 WindowsController.ExitWindows(RestartOptions.Reboot, false);
26 break;
27 case "Stand By":
28 WindowsController.ExitWindows(RestartOptions.Suspend, false);
29 break;
30 case "Hibernate":
31 WindowsController.ExitWindows(RestartOptions.Hibernate, false);
32 break;
33 case "Log Off":
34 WindowsController.ExitWindows(RestartOptions.LogOff, false);
35 break;
36 }
37 }