Closed StevenBaby closed 5 years ago
you'll have to get an instance of ITrayDeskband
and use the methods there. Heres an example
you'll have to get an instance of
ITrayDeskband
and use the methods there. Heres an example
in the program define ITrayDeskband.cs
[ComImport, Guid("6D67E846-5B9C-4db8-9CBC-DDE12F4254F1"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface ITrayDeskband
{
[PreserveSig]
int ShowDeskBand([In, MarshalAs(UnmanagedType.Struct)] ref Guid clsid);
[PreserveSig]
int HideDeskBand([In, MarshalAs(UnmanagedType.Struct)] ref Guid clsid);
[PreserveSig]
int IsDeskBandShown([In, MarshalAs(UnmanagedType.Struct)] ref Guid clsid);
[PreserveSig]
int DeskBandRegistrationChanged();
}
call in program
ITrayDeskband obj = null;
Type trayDeskbandType = System.Type.GetTypeFromCLSID(new Guid("E6442437-6C68-4f52-94DD-2CFED267EFB9"));
try
{
obj = (ITrayDeskband)Activator.CreateInstance(trayDeskbandType);
Guid deskbandGuid = new Guid(DESKBAND_GUID)
obj.DeskBandRegistrationChanged();
hr = obj.ShowDeskBand(ref deskbandGuid);
if (hr != 0)
throw new Exception("Error while trying to show deskband: " + hr);
obj.DeskBandRegistrationChanged();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
finally
{
if (obj != null && Marshal.IsComObject(obj))
Marshal.ReleaseComObject(obj);
}
I registered deskband, but it need click taskbar toolbars to activate, how to activate it automatically?