Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对进程隐藏任务栏(c#)_C#_Taskbar - Fatal编程技术网

对进程隐藏任务栏(c#)

对进程隐藏任务栏(c#),c#,taskbar,C#,Taskbar,在我的应用程序中,我希望在进程启动时隐藏windows任务栏和StartMenuButton,并在进程退出时将其还原 我可以使用以下方法进行此操作: IntPtr startButtonHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, null); IntPtr taskBarHwnd = FindWindow("Shell_TrayWnd", ""); ShowWindow(taskBarHwnd, 0); Sho

在我的应用程序中,我希望在进程启动时隐藏windows任务栏和StartMenuButton,并在进程退出时将其还原

我可以使用以下方法进行此操作:

IntPtr  startButtonHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, null);
IntPtr  taskBarHwnd = FindWindow("Shell_TrayWnd", "");

ShowWindow(taskBarHwnd, 0);
ShowWindow(startButtonHwnd, 0);
这对我来说很好。 现在我看到一个例子,如果我的进程由于某种原因崩溃或被用户强制终止,我将无法恢复任务栏

对于这两个(撞车和死亡)案例,是否有任何恢复方法

我还与Windows Gadget交互,当在应用程序中单击某个按钮时,我会显示一个Gadget窗口,因此我不能使用
Form.TopMost=true
&
Screen.PrimaryScreen.Bounds

谢谢


Vikram

您可以通过将还原代码放入全局异常处理程序来应对大多数崩溃。您可以通过设置


这不适用于程序被终止的情况。

如果explorer.exe被终止/重新启动,您应该小心使用这种方法。IMHO您不能:这两种情况都不能被应用程序捕获。你们可以限制崩溃管理异常,但若用户杀死你们的应用,你们能做什么?你没有收到通知…@马可:如果这真的很重要,一个背景过程。(并不是说它不能终止…)这似乎完全错了。只需全屏显示你的应用程序。
  AppDomain currentDomain = AppDomain.CurrentDomain;
  currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);


static void MyHandler(object sender, UnhandledExceptionEventArgs args)
{
    ShowWindow(taskBarHwnd, 0);
    ShowWindow(startButtonHwnd, 0);
}