我写了一个在任务栏上运行的toolbar.不幸的是,安装后,用户必须手动启用它.有没有办法告诉资源管理器打开(或关闭)给定的工具栏?
我希望安装程序NSIS在安装完成时打开工具栏(我意识到需要一个插件).
我还想知道是否可以为所有用户自动启用工具栏,例如在多个用户共享PC的企业环境中.
解决方法:
> This CodeProject comment does it by simulating key presses
> Vista有这样做的API,ShowDeskBand和HideDeskBand
>编辑:此代码现在可以添加一个deskband对象(来自Pinvoke.net,以及these two MSDN论坛问题):
[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的类似调用也可以做到这一点是有意义的,但到目前为止,我无法使代码工作.另一个问题:当添加它的应用程序关闭时,添加的桌面带关闭.