如何将应用程序固定到任务栏 [英] How to pin an application to the taskbar

查看:91
本文介绍了如何将应用程序固定到任务栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在用户按下表单的最小化按钮时将我的应用程序固定到任务栏,但我不知道该怎么做,或者我的操作系统是否可能是 Windows 10 ...感谢您的帮助

解决方案

当您最小化窗口时,默认情况下,它会在任务栏中最小化.除非您已将其设置为不在此处显示.

如果这是你想要的,你什么都不用做.根据固定它你不应该这样做.

<小时>

不要要求支持固定,这就是原因

Microsoft 竭尽全力防止应用程序改变用户偏好.为什么?因为否则,每个应用程序都会这样做.通过 API 访问用户首选项意味着开发人员开始利用它.这意味着应用程序争夺屏幕空间.您安装了 A 公司的产品,它取消了 B 公司的产品.

如果存在这样的 API,想象一下编写一个替换所有引脚的笑话程序"是多么容易.是的,这是恶意软件.

不,仅用于调用可执行文件的 API 是不可行的,这意味着在操作系统深处的某个地方存在为任何可执行文件执行此操作的函数调用.然后有人找到它并直接调用它.另外,把shell原样解耦也给微软带来了很大的麻烦.

取而代之的是资源管理器处理它.

进一步阅读为什么没有对开始"菜单引脚列表的编程访问?.

因此,答案是请不要这样做".

<小时>

但其他应用做到了...

好的,某些应用程序确实可以固定,他们是如何做到的?

不管我能告诉你的是什么:

  • 这是一种不好的做法.
  • 不能保证它可以工作,更不用说在下一次 Windows 更新中.
<小时>

一种方法是模仿用户输入.很难考虑所有情况(如果任务栏被隐藏了怎么办,如果它不在通常的地方怎么办,如果资源管理器没有运行怎么办等),但是您可以想象设置指针位置和发送键.<小时>

另一种方法是直接写入列表.它在哪里?您可能已经发现固定项目位于:

%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

而且它们是常规的、古老的捷径.你可以添加你自己的.它不会工作.

<小时>

固定的项目实际上是由组策略控制的.显然,这些快捷方式是后备.您需要弄乱 Windows 注册表.请参阅 如何使用组策略管理 Windows 任务栏项目固定.我想我们想要 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband 中的 FavoritesFavoritesResolve.嗯,它不是一个简单的列表,它是二进制的.我最好的猜测是它是某种打包格式的快捷方式文件的转储,祝你好运.

我不会为你解决这个问题.此外,我敢打赌人们在这里找到它,开始利用它,然后 Microsoft 更改它,然后它不起作用.

<小时>

显然在某些时候有一种程序化的方式来做到这一点通过脚本将项目固定到开始菜单或 Windows 7 任务栏.这个想法是从快捷方式中获取一个 shell 对象并在其上运行Pin to Tas&kbar"动词.链接文章中提供的脚本.我不会详细介绍它,因为.... 它不再起作用:

<块引用>

这是 Windows 客户端团队有意改变的行为.我相信 Windows 团队知道这些问题,但您可以通过 Windows 10 反馈应用提供反馈.

您也可以在那里阅读:

<块引用>

固定到开始"菜单或任务栏的项目是用户首选项.应用程序不应覆盖用户的偏好.从长远来看,将不支持以编程方式将项目固定到 Windows 10 中的任务栏或开始菜单.只有用户才能固定项目.

显然它可以通过以管理员权限运行应用程序来工作,无法确认.无论如何,如您所见,没有任何保证.

<小时>

另见:该程序如何将自己固定到我的任务栏我什么时候安装的?.

如果你真的必须这样做,正如陈雷蒙德所说,我希望你能拿到奖金.

I want my application to be pinned to the taskbar when the user press the minimizing button of the form but I have no Idea how to do it or if it is possible my OS is windows 10... Thanks for your help

解决方案

When you minimize your window, by default, it will be minimized in the taskbar. Unless you have set it to not show there.

If that is what you want, you have to do nothing. As per pinning it you should not do it.


Don't ask for support for pinning, here is why

Microsoft goes in great length to prevent applications altering user preferences. Why? Because otherwise, every application would do it. Giving access to user preferences via API means developers start exploiting it. It means applications fighting for screen space. You install compnay A product and it unpins company B product.

If such API existed, imagine how easy would it be to write a "joke program" that replaces all your pins. Yes, that is malware.

And no, an API for only the calling executable is not viable, it would mean that somewhere deep in the operating system the function call to do it for any executable exists. And then somebody finds it and calls it directly. Besides, it has been a big trouble for Microsoft to decouple the shell as it is.

Instead explorer handles it.

Further reading Why is there no programmatic access to the Start menu pin list?.

Thus, the answer is "Please don't do it".


But that other app did it...

Alright, some application do manage to pin, how do they do it?

Regardless of what it is I can tell you:

  • It is a bad practice.
  • It is not guaranteed to work, much less in the next Windows update.

One way is to mimic user input. It is hard to consider all cases (what if the taskbar is hidden, what if it is not in the usual place, what if explorer is not running, etc.), but you can imagine setting the pointer position and sending keys.


Another way would be to write directly to the list. Where is it? You might have found out that the pinned items are at:

%AppData%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

And they are regular, good old, shortcuts. And you could add your own. And it would not work.


The pinned items are actually controlled by group policy. Apparently the shortcuts are a fallback. You would need to mess with Windows registry. See How to manage Windows Taskbar Items pinning using Group Policy. I guess we want Favorites and FavoritesResolve from HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband. Well, it is not a plain list, it is binary. My best guess is that it is a dump of the shortcut files in some packing format, good luck.

I'm not figuring that out for you. Besides, I bet people find it here, start exploiting it, and then Microsoft change it, then it does not work.


Apparently there was at some point a programmatic way to do it Pin Items to the Start Menu or Windows 7 Taskbar via Script . The idea was to get a shell object from the shortcut and run a "Pin to Tas&kbar" verb on it. Script provided in the linked article. I'm not going into detail on it because.... it does no longer work:

it is an intentional change in behavior by the Windows client team. I believe the Windows team is aware of the concerns, but you can provide feedback via the Windows 10 Feedback app.

You can also read there:

The items that are pinned to the Start menu or taskbar is a user preference. Applications should not be overriding the user’s preferences. In the long term, programmaticaly pinning items to the taskbar or Start menu in Windows 10 will not be supported. Only the user will be able to pin items.

Apparently it could work by running the application with administrator privileges, can't confirm. Regardless, as you can see, there are no guarantees.


See also: How did that program manage to pin itself to my taskbar when I installed it?.

If you really have to do it, as Raymond Chen would put it, I hope you get your bonus.

这篇关于如何将应用程序固定到任务栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆