Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I place my custom toolbar (DeskBand?) on taskbar in Windows 7 win WPF?

How do I place my custom toolbar on taskbar in Windows 7 before tasks panel? There is a popular application called Pokki which does it. enter image description here I wonder how do I do the same?

Edit1: I need a 100% way to a custom toolbar (DeskBand?) for Windows 7. I'm not looking for a pin-an application solution, rather a way to build a custom solution capable of processing it's own messages and displaying it's own icons. C# way is greatly appreciated.

Edit2: WPF way is greatly appreciated.

like image 394
Artem Avatar asked Dec 08 '22 18:12

Artem


2 Answers

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.

like image 151
Hans Passant Avatar answered Dec 11 '22 06:12

Hans Passant


The following example may help:

http://www.codeproject.com/Articles/185512/Programmatically-PIN-shortcut-onto-Taskbar-on-Win7

like image 24
PeterJ Avatar answered Dec 11 '22 08:12

PeterJ