示例#1
0
 public static void PreventSleep()
 {
     if (SEBProcessHandler.SetThreadExecutionState(SEBProcessHandler.EXECUTION_STATE.ES_SYSTEM_REQUIRED | SEBProcessHandler.EXECUTION_STATE.ES_DISPLAY_REQUIRED | SEBProcessHandler.EXECUTION_STATE.ES_AWAYMODE_REQUIRED | SEBProcessHandler.EXECUTION_STATE.ES_CONTINUOUS) != (SEBProcessHandler.EXECUTION_STATE) 0)
     {
         return;
     }
     int num = (int)SEBProcessHandler.SetThreadExecutionState(SEBProcessHandler.EXECUTION_STATE.ES_SYSTEM_REQUIRED | SEBProcessHandler.EXECUTION_STATE.ES_DISPLAY_REQUIRED | SEBProcessHandler.EXECUTION_STATE.ES_CONTINUOUS);
 }
示例#2
0
        private void ExplorerStarted()
        {
            Logger.AddWarning("Windows explorer has been restarted!", this);

            var success = SEBProcessHandler.KillExplorerShell();

            if (success)
            {
                Logger.AddInformation("Successfully terminated Windows explorer.", this);
            }
            else
            {
                Logger.AddError("Failed to terminate Windows explorer!", this, null);
            }
        }
示例#3
0
        private void ExplorerStarted(object sender, EventArgs e)
        {
            Logger.AddWarning("Windows Explorer has been restarted!", this);

            var success = SEBProcessHandler.KillExplorerShell();

            if (success)
            {
                SEBClientInfo.SebWindowsClientForm?.Invoke(new Action(() => SEBClientInfo.SebWindowsClientForm?.PlaceFormOnDesktop(false)));
                Logger.AddInformation("Successfully terminated Windows Explorer.", this);
            }
            else
            {
                Logger.AddError("Failed to terminate Windows Explorer!", this, null);
            }
        }
示例#4
0
 public static bool KillExplorerShell()
 {
     try
     {
         IntPtr window = SEBProcessHandler.FindWindow("Shell_TrayWnd", (string)null);
         if (window != IntPtr.Zero)
         {
             SEBProcessHandler.PostMessage(window, 1460U, IntPtr.Zero, IntPtr.Zero);
             while (SEBProcessHandler.FindWindow("Shell_TrayWnd", (string)null) != IntPtr.Zero)
             {
                 Thread.Sleep(500);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         Logger.AddInformation("{0} {1}", (object)ex.Message, (Exception)null, (string)null);
         return(false);
     }
 }
示例#5
0
        public static void StartExplorerShell(bool waitForStartup = true)
        {
            if (!(SEBProcessHandler.FindWindow("Shell_TrayWnd", (string)null) == IntPtr.Zero))
            {
                return;
            }
            string str = string.Format("{0}\\{1}", (object)Environment.GetEnvironmentVariable("WINDIR"), (object)"explorer.exe");

            new Process()
            {
                StartInfo =
                {
                    FileName         = str,
                    UseShellExecute  = true,
                    WorkingDirectory = Application.StartupPath,
                    CreateNoWindow   = true
                }
            }.Start();
            for (int index = 0; index < 6; ++index)
            {
                Logger.AddInformation("waiting for explorer shell to get up " + (object)index + " seconds", (object)null, (Exception)null, (string)null);
                if (!(SEBProcessHandler.FindWindow("Shell_TrayWnd", (string)null) != IntPtr.Zero))
                {
                    Thread.Sleep(1000);
                }
                else
                {
                    break;
                }
            }
            if (!waitForStartup)
            {
                return;
            }
            Logger.AddInformation("waiting for explorer shell to finish starting 6 seconds", (object)null, (Exception)null, (string)null);
            Thread.Sleep(6000);
        }