Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load deskband another program? #41

Closed
StevenBaby opened this issue May 8, 2019 · 2 comments
Closed

How to load deskband another program? #41

StevenBaby opened this issue May 8, 2019 · 2 comments

Comments

@StevenBaby
Copy link

I registered deskband, but it need click taskbar toolbars to activate, how to activate it automatically?

@dsafa
Copy link
Owner

dsafa commented May 8, 2019

you'll have to get an instance of ITrayDeskband and use the methods there. Heres an example

@StevenBaby
Copy link
Author

you'll have to get an instance of ITrayDeskband and use the methods there. Heres an example

Thanks, that work.

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);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants