public static void HideBand(Type t) { ITrayDeskband csdeskband = null; try { Type trayDeskbandType = Type.GetTypeFromCLSID(new Guid("E6442437-6C68-4f52-94DD-2CFED267EFB9")); Guid deskbandGuid = t.GUID; csdeskband = (ITrayDeskband)Activator.CreateInstance(trayDeskbandType); if (csdeskband != null) { csdeskband.DeskBandRegistrationChanged(); if (csdeskband.IsDeskBandShown(ref deskbandGuid) == HRESULT.S_OK) { csdeskband.HideDeskBand(ref deskbandGuid); } } } catch (Exception e) { Console.WriteLine($"Error while trying to show deskband: {e.ToString()}"); } finally { if (csdeskband != null && Marshal.IsComObject(csdeskband)) { Marshal.ReleaseComObject(csdeskband); } } }
public int IsShellShown() { ITrayDeskband obj = null; Type trayDeskbandType = System.Type.GetTypeFromCLSID(new Guid("E6442437-6C68-4f52-94DD-2CFED267EFB9")); obj = (ITrayDeskband)Activator.CreateInstance(trayDeskbandType); obj.DeskBandRegistrationChanged(); return(obj.IsDeskBandShown(ref deskbandGuid)); }
public static void Register(Type t) { var guid = t.GUID.ToString("B"); try { var registryKey = Registry.ClassesRoot.CreateSubKey($@"CLSID\{guid}"); registryKey.SetValue(null, GetToolbarName(t)); var subKey = registryKey.CreateSubKey("Implemented Categories"); subKey.CreateSubKey(ComponentCategoryManager.CATID_DESKBAND.ToString("B")); Console.WriteLine($"Succesfully registered deskband `{GetToolbarName(t)}` - GUID: {guid}"); if (GetToolbarRequestToShow(t)) { Console.WriteLine($"Request to show deskband."); // https://www.pinvoke.net/default.aspx/Interfaces.ITrayDeskband ITrayDeskband csdeskband = null; try { Type trayDeskbandType = Type.GetTypeFromCLSID(new Guid("E6442437-6C68-4f52-94DD-2CFED267EFB9")); Guid deskbandGuid = t.GUID; csdeskband = (ITrayDeskband)Activator.CreateInstance(trayDeskbandType); if (csdeskband != null) { csdeskband.DeskBandRegistrationChanged(); if (csdeskband.IsDeskBandShown(ref deskbandGuid) == HRESULT.S_FALSE) { if (csdeskband.ShowDeskBand(ref deskbandGuid) != HRESULT.S_OK) { Console.WriteLine($"Error while trying to show deskband."); } if (csdeskband.DeskBandRegistrationChanged() == HRESULT.S_OK) { Console.WriteLine($"The deskband was Succesfully shown with taskbar.{Environment.NewLine}You may see the alert notice box from explorer call."); } } } } catch (Exception e) { Console.WriteLine($"Error while trying to show deskband: {e.ToString()}"); } finally { if (csdeskband != null && Marshal.IsComObject(csdeskband)) { Marshal.ReleaseComObject(csdeskband); } } } } catch (Exception) { Console.Error.WriteLine($"Failed to register deskband `{GetToolbarName(t)}` - GUID: {guid}"); throw; } }