问题
I am trying to add a button to one of the existing tool bars in any windows explorer instance.
After much research i figured out that BHO (browser helper objects) are the best way to hook
to windows explorer.
My question is :
- Is that the correct way to go about it ?
- In the SetSite of the BHO i get the comObject that is the explorer window. What now ?
- If i can get the hWnd of the explorer window can i use win API to add my button ?
Note i am developing in C# for XP.
Thanks.
回答1:
1 In pre-XP you can add custom items in the default folder template because the folder window is actually a webpage. In XP and later that is no longer true. A Deskband is the supported way to extend the UI. 2 The site is the same. You can even sink DWebBrowserEvents2 to get notified when the folder view is ready. 3 using window functions on explorer is not supported. The supported way to customize the explorer is to create deskbands. it is theoretically possible if you have the resource to test your code against each and every version of Windows Explorer used by your client audience and continue to do compatibility testing when each new version (or new language) of explorer.exe is released.
BHO can not add deskband. If you want to start BHO and deskband programming, look at Paul DiLascia's article "My Band is Your Band" in the November 1999 issue of MSJ. There is another article "Building Browser Helper Objects with Visual Studio 2005" in MSDN for BHO. Basically you need to handle the DocumentComplete and BeforeNavigate events and be careful not to access the folder view when the document is not ready. You can use any communication method that you see fit between your BHO and your deskband, such as hidden window with special window class, static variable if the two are in the same dll, shared memory, named pipe, etc.
Microsoft does not support creating In-Process extensions in managed code until .Net 4.0
来源:https://stackoverflow.com/questions/1744980/how-can-i-add-a-button-to-all-windows-explorer-instances