如何在任务面板之前将自定义工具栏放在 Windows 7 的任务栏上?有一个名为 Pokki 的流行应用程序可以做到这一点。 我想知道我该怎么做?
Edit1:我需要一种 100% 的方式来为 Windows 7 定制工具栏(DeskBand?)。我不是在寻找一个固定应用程序解决方案,而是一种构建能够处理它自己的消息并显示它的定制解决方案的方法自己的图标。非常感谢 C# 方式。
Edit2:非常感谢 WPF 方式。
You'll get plenty of advice to not do this in C#. I cannot recommend otherwise, the odds that your deskband will not work are great. At issue is the CLR version injection problem, a process (like explorer.exe) can have only one version of the CLR loaded. And your deskband will not work when it is the wrong version.
There were very specific counter-measures against this problem added in .NET 4.0, its CLR supports in-process side-by-side versions of the CLR. In other words, having more than one CLR loaded in a single process. That feature works in this specific scenario, a COM server that needs the CLR because it was written in managed code. So an absolute requirement is that you'd write your extension targeting .NET 4.0 or better.
But there is still a legacy problem, and the core reason that Microsoft still does not support this scenario for shell extensions. There is a "who comes first" problem. Despite the warning not to do this, there are shell extensions out there that use managed code and target CLR version 2. If such an extension gets loaded before yours, an entirely random event since it depends on the order of keys in the registry, Explorer might get CLR 2 loaded first. Which then prevents the inprocess side-by-side feature from working, it can only come to a good end when CLR version 4 is loaded first.
This is utterly undiagnosable, Explorer doesn't squeak when an extension can't be loaded. And unfixable to the average user, you cannot expect him to tinker with obscure registry keys.
It is going to take a lot of time before this problem can be dismissed completely. Realistically, Windows needs to stop supporting .NET versions prior to .NET 4 to have a guarantee. Windows 8 made a start by not having .NET 3.5 installed by default but it still makes it very easy to add it. So make that a lot of time, a decade or more.
Well, caution to the wind, you can make it work in C# if you don't worry about random failure. You'll next get buried in very obscure COM interface details, surviving them requires black-belt skills with knowing how to properly declare a [ComImport] interface. This is not something you ought to tackle yourself, it has been done by others. I'm not in the habit of recommending products, but can't skip recommending EZShellExtensions, a library specifically designed to help writing shell extensions in C#. Support for deskbands is one of its advertized features. Use the trial version to tinker with this to see if you can bring this to a good end.
以下示例可能会有所帮助:
http://www.codeproject.com/Articles/185512/Programmatically-PIN-shortcut-onto-Taskbar-on-Win7