简体   繁体   中英

Icon Handler Shell Extension not called

I used VS2015 and the ATL project wizard to write a Shell Extension Icon handler . I created a COM object to expose the IPersist and IExtractIcon interfaces. I can see that the handler is registered when I look at the registry entry for the specific file type. Here's what the class looks like:

class ATL_NO_VTABLE CIconHandlerExt :
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CIconHandlerExt, &CLSID_IconHandlerExt>,
    public IIconHandlerExt,
    public IPersistFile,
    public IExtractIcon
{
public:
    CIconHandlerExt()
    {
    }

    DECLARE_PROTECT_FINAL_CONSTRUCT()

    HRESULT FinalConstruct()
    {
        return S_OK;
    }

    void FinalRelease()
    {
    }

DECLARE_REGISTRY_RESOURCEID(IDR_ICONHANDLEREXT)

DECLARE_NOT_AGGREGATABLE(CIconHandlerExt)

BEGIN_COM_MAP(CIconHandlerExt)
    COM_INTERFACE_ENTRY(IIconHandlerExt)
    COM_INTERFACE_ENTRY(IPersistFile)
    COM_INTERFACE_ENTRY(IExtractIcon)
END_COM_MAP()

// IIconHandlerExt
public:

    // IExtractIcon
    STDMETHODIMP GetIconLocation(UINT uFlags, LPTSTR szIconFile, UINT cchMax, int* piIndex, UINT* pwFlags);
    STDMETHODIMP Extract(LPCTSTR pszFile, UINT nIconIndex, HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize);

public:
    // IPersistFile
    //xxxSTDMETHOD(GetClassID)(CLSID*) { return E_NOTIMPL; }
    STDMETHOD(GetClassID)(CLSID *pClsId) { *pClsId = CLSID_IconHandlerExt;  return S_OK; }
    STDMETHOD(IsDirty)() { return E_NOTIMPL; }
    STDMETHOD(Save)(LPCOLESTR, BOOL) { return E_NOTIMPL; }
    STDMETHOD(SaveCompleted)(LPCOLESTR) { return E_NOTIMPL; }
    STDMETHOD(GetCurFile)(LPOLESTR*) { return E_NOTIMPL; }
    STDMETHOD(Load)(LPCOLESTR wszFile, DWORD /*dwMode*/)
    {
        USES_CONVERSION;
        lstrcpyn(m_szFilename, OLE2CT(wszFile), MAX_PATH);
        return S_OK;
    }

protected:
    TCHAR     m_szFilename[MAX_PATH];  // Full path to the file in question.

};

OBJECT_ENTRY_AUTO(__uuidof(IconHandlerExt), CIconHandlerExt)

I used the instructions in this post to start the debugging session. Namely, I click the task bar, hit Alt-F4, Press Ctrl-Alt-Shift-Escape, and start my debugger session that specifies Windows Explorer as the command target. I set breakpoints and navigate to the test file.

My handler is never loaded since the breakpoints are not hit and they say

“The breakpoint will not currently be hit. No symbols have been loaded for this document.”

Can anyone shed light on why my extension does not load?

This question has been solved.

The Shell Extension requires making an update to the wizard generated registry script to identify the handler that should be used for the particular file type. I did not pay attention to the key I was updating (from within the registry script) and updated the wrong key. In my case, the file type I was trying to add a handler for was “mcam”. So, I updated the “HKCR.mcam” key. This is incorrect because the purpose of this initial key is to point (via a “mcamFile” sub-key) to the actual registry key that determines what handler to load. Once I changed the script to update the “HKCR\\mcamFile” key, the handler was loaded and I was able to debug my code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM