从进程中隐藏任务栏 (c#)
在我的应用程序中,我想在进程启动时隐藏 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
谢谢,
维克拉姆
In my application, I want to hide the windows TaskBar and StartMenuButton when my process is started and want to restore it when it exits.
I can do this using:
IntPtr startButtonHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, (IntPtr)0xC017, null);
IntPtr taskBarHwnd = FindWindow("Shell_TrayWnd", "");
ShowWindow(taskBarHwnd, 0);
ShowWindow(startButtonHwnd, 0);
and this is working fine for me.
Now I see a case where, if my process is crashed for some reason or is FORCIBLY killed by user, I won't be able to restore the TaskBar.
Is there any method of restoring it for these TWO (crash and killed) cases?
I am also interacting with Windows Gadget and I show a Gadget window when some button is clicked in my application, so I can not use properties like Form.TopMost = true
& Screen.PrimaryScreen.Bounds
Thanks,
Vikram
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过将恢复代码放入全局异常处理程序来应对大多数崩溃。您可以通过设置未处理的异常处理程序来完成此操作
这不能满足程序被杀死的情况。
You can cater for most crashes by putting the restore code in a global exception handler. You can do this by setting up an unhandled exception handler
This won't cater for the case where the program is killed.