How to prevent an app from being pinned in Windows 7?

前端 未结 3 995
逝去的感伤
逝去的感伤 2021-02-10 03:48

I am trying to prevent the user from pinning my .NET app to the taskbar. I\'ve found some code on the Old New Thing that does just that. However, it is in C++.



        
3条回答
  •  轮回少年
    2021-02-10 04:51

    Using the WindowsAPICodePack (via NuGet) you need code resembling:

    // Ensure the handle is available
    new WindowInteropHelper(window).EnsureHandle();
    
    // Prevent the window from being pinned to the task bars
    var preventPinningProperty = new PropertyKey(
            new Guid("9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3"), 9);
    WindowProperties.SetWindowProperty(window, preventPinningProperty, "1");
    

提交回复
热议问题