问题描述
我编写了在任务栏上运行的工具栏.不幸的是,安装后,用户必须手动启用它.有没有办法告诉浏览器打开(或关闭)给定的工具栏?
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?
我希望安装程序NSIS在安装完成后打开工具栏(我意识到必须使用插件).
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).
我还想知道是否可以为所有用户自动启用工具栏,例如在公司环境中,其中有多个用户共享一台PC.
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.
推荐答案
- 此CodeProject注释通过模拟键来完成按下
- Vista +具有使用 ShowDeskBand 和 HideDeskBand
-
此代码现在可以添加一个桌面带对象(来自Pinvoke.net和这些 两个 MSDN论坛问题):
- This CodeProject comment does it by simulating key presses
- Vista+ has API to do this, with ShowDeskBand and HideDeskBand
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); }
还有一个示例用法:
Guid address_toolbar_guid = new Guid("{01E04581-4EEE-11D0-BFE9-00AA005B4383}"); uint band_id = AddDeskbandToTray(address_toolbar_guid);
有意义的是,对RemoveBand的类似调用也可以解决问题,但是到目前为止,我无法使该代码正常工作.另一个问题:添加的桌带在添加应用程序的应用程序关闭时关闭.
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.
这篇关于如何以编程方式告诉Windows任务栏打开(或关闭)给定的工具栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!