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); } }
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); }