Extend Windows explorer with BHO

2019-06-20 22:59发布

问题:

I am trying to extend whindows explorer (NOT IE) with a customized panel in C++, which should look like this:

and here's a similar question I found (in C#) : Similar question

The question is of C# and already got an answer.

But I myself find the answer is a bit too brief for me to follow, here's what I got:

  1. I should implement a BHO object
  2. the BHO object should implemet IObjectWithSite and IDockingWindow
  3. In SetSite method, call QueryInterface to get the pointer of service provider, then call QueryService to get the pointer of a Docking window frame, then finally call AddToolBar to add my customized window. and here's where I got lost

and my questions are:

  1. at what time should I create my customized window? during the initialization of the object?
  2. I think I should get a parent window's handle (in my case I think it should be the windows explorer's handle) before I can create my own window which will be a child of it, where can I get this handle? with the pointer of docking window frame ?
  3. How should I register my dll? I read some sample codes of preview handlers, we have to register the dll properly before it can be invoked by the system right?

I've tried to reproduce what the similar question said for days, but no luck by now.

I'm really new to BHO and all such stuff, kindly please help me out of this, thanks.

回答1:

For such Explorer extension I create 2 object. First implements BHO (IDispatch and IObjectWithSite). Second implements IObjectWithSite, IOleWindow, IDockingWindow, IInputObject and IOleCommandTarget.

1) The logic of showing of your window depends on what you want to realize.

2) Parent window you can get inside Second.SetSite:

Site.QueryInterface(IDockingWindowSite, FDockingWindowSite);
FDockingWindowSite.GetWindow(FParent);

3) Just register your BHO as standard BHO.

It took a LONG time for me to create and debug such extension. If you are not expert in this sphere think again - do you really need this functionality. But if you really decided you need then try to create and register simple BHO first. And only when BHO works correctly add IDockingWindow implementation.