在Windows 10上,是否可以在Winforms应用程序中以编程方式固定应用程序?

huangapple go评论216阅读模式
英文:

Is it possible to pin app programmatically in Winforms app on windows 10?

问题

我正在尝试构建一个示例应用程序来检查固定功能。我看到了这篇文章https://learn.microsoft.com/en-us/windows/apps/design/shell/pin-to-taskbar,它演示了逐步的过程。我只想知道这对WinForms和WPF是否也适用,还是只适用于UWP应用程序。

我尝试使用WinForms,但遇到了异常
System.Runtime.InteropServices.COMException (0x80070490):找不到元素。 (0x80070490)

英文:

I am trying to build a sample app to check pinning functionality. I came across this article https://learn.microsoft.com/en-us/windows/apps/design/shell/pin-to-taskbar which demonstrates the step by step procedure. I just want to know if this is possible for WinForms and WPF as well or only for UWP apps

I was trying with winforms and was getting exception
System.Runtime.InteropServices.COMException (0x80070490): Element not found. (0x80070490)

答案1

得分: 1

I'm not sure if there are other ways rather than WinRT APIs that could do it. But just talk from the UWP side, the TaskbarManager class you find in the document can't be used in normal desktop apps like WPF and WinForms. You will get an exception when you are trying to get the TaskbarManager instance.

You might also check Raymond Chen's blog here: How did that program manage to pin itself to my taskbar when I installed it?

英文:

I'm not sure if there are other ways rather than WinRT APIs that could do it. But just talk from the UWP side, the TaskbarManager class you find in the document can't be used in normal desktop apps like WPF and WinForms. You will get exception when you are trying to get the TaskbarManager instance.

You might also check Raymond Chen's blog here: How did that program manage to pin itself to my taskbar when I installed it?

huangapple
  • 本文由 发表于 2023年7月6日 18:37:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76627948.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定