5

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

enter image description here

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.

Community
  • 1
  • 1
Sean
  • 563
  • 1
  • 7
  • 18
  • 3
    BHOs are evil. Any bug in a BHO becomes a system bug. So for someone who is unsure about the details of the COM technology, I recommend *not doing it* (for that matter, I recommend that in general). – Cheers and hth. - Alf Jul 27 '14 at 09:43
  • ye, got ur point and totally agree. but somehow our system need such feature and it seems indispensable, do u happen know any other way to achieve my purpose other than BHO? @Cheersandhth.-Alf – Sean Jul 27 '14 at 09:57
  • if you want the ability to do something with a selected drive, register a handler for the right click menu for drives. that's *very* simple to do. your handler program gets the drive as command line parameter, and the user sees it in the right click menu for the drive. – Cheers and hth. - Alf Jul 27 '14 at 10:01
  • 1
    as an example, set the default value of [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\say_ah] to “Say "Ah!"”. Then set the default value of [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\say_ah\command] to “cmd /k echo Ah! - %1”. Works nicely. – Cheers and hth. - Alf Jul 27 '14 at 10:11
  • 3
    What Alf says is spot on - push back to your management and let them know that not even Microsoft encourages this. But if you must, go order any used copy you can find of Dino's book: http://www.amazon.com/Visual-C-Windows-Shell-Programming/dp/1861001843/ref=sr_1_1?ie=UTF8&qid=1406456530&sr=8-1&keywords=dino+esposito+shell+programming I think it's the only book ever written on the topic. – selbie Jul 27 '14 at 10:25
  • thanks a lot for the example @Cheersandhth.-Alf , but what we are trying to do is like a preview pane in win7, only it's for all kind of files, folders or disk drives, and some simple operations are also required, a right click menu might not be enough. – Sean Jul 27 '14 at 11:32
  • hooray, a cookbook finally. I think my friend has one, just never came to my mind that's the book. thanks @selbie – Sean Jul 27 '14 at 11:36

1 Answers1

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.

Denis Anisimov
  • 3,297
  • 1
  • 10
  • 18
  • wow, cool, man! great & really fast explainations! Will try this out ! thanks again, man. – Sean Jul 27 '14 at 11:20
  • after a lot of search, I finally got it working by following your instructions. it works. – Sean Aug 03 '14 at 09:09