views:

1241

answers:

3

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?

A: 

Does this help?

http://www.codeproject.com/KB/shell/dotnetbandobjects.aspx

Miral
A: 

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

Eirik Nygaard
+1  A: 

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