问题
I maintain a explorer/file manager tool (xplorer2) that can replace windows explorer for opening folders. However I cannot trap the "open folder and select item" operation performed by SHOpenFolderAndSelectItems API.
I found an old thread by some other file manager programmer which implied that the right way is to register the "explorer-like" tool as a shell window, then respond to some queries to supply interfaces and services like IWebBrowserApp that will allow the item(s) to be selected
I registered my top level window with the shell windows successfully as such
CComPtr<IShellWindows> pShellWindows;
HRESULT hr = pShellWindows.CoCreateInstance(CLSID_ShellWindows);
hr = pShellWindows->Register(static_cast<IDispatch*>(this),
(SHANDLE_PTR)hwTop, /*SWC_3RDPARTY*/SWC_EXPLORER, &m_dwCookie);
ATLASSERT(SUCCEEDED(hr));
the window does appear if enumerated among the shell windows. However when it is launched as a result of SHOpenFolderAndSelectItems (it is declared as an explorer replacement in HKEY_CLASSES_ROOT\Directory\shell), there are no attempts to QueryInterface or any other action on the IDispatch registered. I have tried both SWC_3RDPARTY and SWC_EXPLORER registration flags without any luck
any ideas what am I doing wrong?
回答1:
ok, I figured it out. The trick is really going round the buggy documentation
来源:https://stackoverflow.com/questions/22118653/shopenfolderandselectitems-for-explorer-replacement-program