I have written a toolbar that runs on the taskbar. Unfortunately, after it is installed, the user has to enable it manually. Is there a way to tell explorer to open (or close) a given toolbar?
I would like for the installer, NSIS, to turn on the toolbar when the installation is complete (I realize that a plugin would be necessary).
I also want to know if it's possible to automatically enable a toolbar for all users, for example in a corporate environment where multiple users would share a PC.
- This CodeProject comment does it by simulating key presses
- Vista+ has API to do this, with ShowDeskBand and HideDeskBand
Edit: This code can now Add a deskband object (from Pinvoke.net, and these two MSDN forum questions):
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("4CF504B0-DE96-11D0-8B3F-00A0C911E8E5")]
public interface IBandSite
{
[PreserveSig]
uint AddBand([In, MarshalAs(UnmanagedType.IUnknown)] Object pUnkSite);
[PreserveSig]
void RemoveBand(uint dwBandID);
}
private uint AddDeskbandToTray(Guid Deskband)
{
Guid IUnknown = new Guid("{00000000-0000-0000-C000-000000000046}");
Guid ITrayBand = new Guid("{F60AD0A0-E5E1-45cb-B51A-E15B9F8B2934}");
Type TrayBandSiteService = Type.GetTypeFromCLSID(ITrayBand, true);
IBandSite BandSite = Activator.CreateInstance(TrayBandSiteService) as IBandSite;
object DeskbandObject = CoCreateInstance(Deskband, null, CLSCTX.CLSCTX_INPROC_SERVER, IUnknown);
return BandSite.AddBand(DeskbandObject);
}
And, an example use:
Guid address_toolbar_guid = new Guid("{01E04581-4EEE-11D0-BFE9-00AA005B4383}");
uint band_id = AddDeskbandToTray(address_toolbar_guid);
It would make sense that a similar call to RemoveBand would also do the trick, but as of yet, I can't get that code to work. Another issue: the added deskband closes when the application that added it closes.
You might want to check out this article. It looks like you can only do this ("officially" anyway) in Vista using the ITrayDeskBand interface.
I can't find the exact url right now, but I remember there being some discussion of this around PDC2008 where basically this was not enabled specifically so that random programs couldn't populate the taskbar w/o the users consent.
A side effect of this is that very few users even enable the WMP deskbar by default.
From what I understand, taskbars locations and values etc are stored in the registry (forgot exact location) so if you find the specific registry key you could take its location and make your installer insert the registry key on the computer so the taskbar is enabled.
Not really an answer to your question, but please, please: do not write shell extensions (and a taskbar is a shell extension) in .NET!
Here's why.
Basically, you're breaking other apps.
if you check well, google toolband exists while an exe is running behind (GoogleDesktop.exe) so if you insist on the way google or search bar are instantiated you should check again TrayBandSiteService and make a support exe...