Eirik Nygaard
Eirik Nygaard

Reputation: 91

Toolbar on windows xp and vista taskbar

I have made a toolbar that I want to enable from a systray application written in C#, the actual toolbar enabling is done from a C++ part using [DLLImport].

Current I use:

SHLoadInProc(__uuidof(MyBandLoader))

but this fails on vista (SHLoadInProc is not implemented any more), and on Windows XP SP2 with IE6 (the quick launch toolbar vanishes after reboot).

On Vista I have tried to with: CocreateInstance() and BandSite->AddBand(), but using the guid of the toolbar dll gave me either a segmentation fault or the address bar.

Is there another way to enable a toolbar from another program on XP and Vista?

Upvotes: 1

Views: 2207

Answers (3)

philk
philk

Reputation: 2140

One should never use .Net to create any COM objects inside the Explorer process. This will just not work if there is another .net component using a different framework version already loaded into the explorers process. Only one .net framework for each process. MS should have never propaged samples about developing deskbands in any .net language.

The only way on Vista an up is to use the ITrayDeskBand interface to display the toolbar. However, this will display a confirmation box to the user and he can refuse the toolbar to be shown.

Upvotes: 0

user6586
user6586

Reputation: 206

On Vista there's a new poorly-documented interface called ITrayDeskBand.

Create an instance of this via CoCreateInstance, and then call ShowDeskBand([CLSID of your toolbar]) on the returned pointer (in C++ - I'm not sure how you create all the relevant bits for PInvoke in C# - might be easier to write a simple C++ dll to expose this function)

That only works on Vista though, on XP you need to continue with the SHLoadInProc method above, so you need to test the OS version and do the appropriate thing.

Be careful if you're lifting code from that codeproject article - it's full of subtle bugs, although many of them are discussed in the comments

Upvotes: 1

Eirik Nygaard
Eirik Nygaard

Reputation: 91

I have used that one, but it only tells you have to make a toolbar, not how to enable it from another program.

Upvotes: 0

Related Questions