簡體   English   中英

從進程中隱藏TaskBar(c#)

[英]Hiding TaskBar from a process (c#)

在我的應用程序中,我希望在我的進程啟動時隱藏窗口TaskBar和StartMenuButton,並希望在退出時恢復它。

我可以這樣做:

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

ShowWindow(taskBarHwnd, 0);
ShowWindow(startButtonHwnd, 0);

這對我來說很好。 現在我看到一個案例,如果我的進程由於某種原因崩潰或者被用戶強行殺死,我將無法恢復TaskBar。

是否有任何方法可以恢復這兩個(崩潰和死亡)案件?

我也在與Windows Gadget交互,當我在我的應用程序中單擊某個按鈕時,我會顯示一個Gadget窗口,因此我無法使用Form.TopMost = trueScreen.PrimaryScreen.Bounds

謝謝,

維克拉姆

通過將還原代碼放在全局異常處理程序中,可以滿足大多數崩潰的需要。 您可以通過設置未處理的異常處理程序來完成此操作

  AppDomain currentDomain = AppDomain.CurrentDomain;
  currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);


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

這不符合程序被殺的情況。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM