BHO:c2259无法实例化抽象类

时间:2013-11-21 10:03:42

标签: c++ .net visual-studio visual-c++

我正在尝试构建BHO,但编译器说:

  

Microsoft Visual Studio .NET 2003 \ Vc7 \ atlmfc \ include \ atlcom.h(1759):

     

错误C2259:'ATL :: CComObject':无法实例化抽象

     

    with
    [
        Base=CSample
    ]

如何解决此错误? 我知道我正在使用旧VS但我现在需要它。

#ifndef __Sample_H_
#define __Sample_H_

#include "resource.h"      
#include "ExDisp.h"
//#include <shlguid.h>
//#include <mshtml.h>

#include "BhoPlugin.h"
#include "ExDispID.h"
#include "mshtml.h"
#include "wininet.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

class ATL_NO_VTABLE CSample : 
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CSample, &CLSID_Sample>,
    public IObjectWithSiteImpl<CSample>,
    public IDispatchImpl<ISample, &IID_ISample, &LIBID_BHOPLUGINLib>,
    public IOleCommandTarget
{
public:
    CSample()
    {
    }

DECLARE_REGISTRY_RESOURCEID(IDR_Sample)

DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CSample)
    COM_INTERFACE_ENTRY(ISample)
    COM_INTERFACE_ENTRY(IDispatch)
    COM_INTERFACE_ENTRY(IObjectWithSite)
    COM_INTERFACE_ENTRY(IOleCommandTarget)
END_COM_MAP()

public:
    CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> mWebBrowser2;

    HRESULT RegisterEventHandler(BOOL inAdvise);
    STDMETHOD(Invoke)(DISPID dispidMember,REFIID riid, LCID lcid, WORD wFlags,
                     DISPPARAMS * pDispParams, VARIANT * pvarResult,
                     EXCEPINFO * pexcepinfo, UINT * puArgErr);

        STDMETHOD(SetSite)(IUnknown *pUnkSite);

        STDMETHOD(Exec)(const GUID *pguidCmdGroup, DWORD nCmdID, 
        DWORD nCmdExecOpt, VARIANTARG *pvaIn, VARIANTARG *pvaOut);


private:
    CComPtr<IWebBrowser2> m_spWebBrowser;
    CComQIPtr<IOleCommandTarget, 
        &IID_IOleCommandTarget> m_spTarget;

};


#endif 

0 个答案:

没有答案