IObjectSite仅适用于Internet Explorer,但我想要Windows资源管理器

时间:2014-03-04 14:42:43

标签: c# internet-explorer winapi bho windows-explorer

我有以下代码来获得Windows资源管理器的BHO。如何将其更改为仅使用Windows资源管理器而不是Internet Explorer?

由于

[
ComVisible(true),
Guid("8a194578-81ea-4850-9911-13ba2d71efbd"),
ClassInterface(ClassInterfaceType.None)
]
public class BHO:IObjectWithSite
{
      WebBrowser webBrowser;
      public void OnDocumentComplete(object pDisp, ref object URL)
      { 
          System.Windows.Forms.MessageBox.Show("Hi");
      }

      public int SetSite(object site)
      {
        if (site != null)
        {
            webBrowser = (WebBrowser)site;
            webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
        }
      }

      public int GetSite(ref Guid guid, out IntPtr ppvSite)
      {
        IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);
        int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);
        Marshal.Release(punk);

        return hr;
      }
 }

0 个答案:

没有答案