Remove application from taskbar with C# wrapper?

后端 未结 1 1511
一整个雨季
一整个雨季 2021-01-16 11:03

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 supp

1条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-16 11:54

    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.

    0 讨论(0)
提交回复
热议问题