Remove application from taskbar with C# wrapper?

て烟熏妆下的殇ゞ 提交于 2019-12-30 12:24:24

问题


Is there a way to build a C# wrapper for an existing application that will allow me to remove it from the taskbar?

More info:

I have an timer app that I suppose to use but don't because it well... sucks. See https://superuser.com/questions/92774/quickbooks-timer-replacement-windows.

So to make it suck less I wonder if I can build a wrapper then just interact with that wrapper instead. Removing the timer from the taskbar and then having my app hid/show it would be a step in that direction.

The other option is to reverse engineer the timer. But that is another project for another day. Right now I would be happy with hiding the thing.


回答1:


You would need to locate the window that is being represented in the taskbar, and remove the "show in taskbar" bit from its (extended) style. This will involve dropping down to the Windows API level. The functions you will need are:

  • GetWindowLongPtr - to retrieve the existing extended style (GWL_EXSTYLE)
  • SetWindowLongPtr - to set the new existing extended style (GWL_EXSTYLE)

The extended style bit you need to remove is WS_EX_APPWINDOW.

Please see the SetWindowLongPtr docs for info about restrictions on the use of SetWindowLongPtr to affect windows in other threads, and potentially needing to call SetWindowPos to cause a visual update. Windows may even prevent you from doing this altogether (e.g. for security or usability reasons)

I haven't tested this and it may depend on the target application. Finally, if this does work it will remove the window from the taskbar altogether, which may be confusing when you re-show the window, so your app may want to re-enable the WS_EX_APPWINDOW style before showing the other app's window.



来源:https://stackoverflow.com/questions/2157712/remove-application-from-taskbar-with-c-sharp-wrapper

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!