关于在 ATL EXE 内部建立对象
我写了一个 ATL 的exe ,在外部可以正常调用 这个ATL 的COM 对象 。
这个COM 对象形如:
class ATL_NO_VTABLE CSipPhoneControl :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CSipPhoneControl, &CLSID_SipPhoneControl>,
public IConnectionPointContainerImpl<CSipPhoneControl>,
public CProxy_ISipPhoneControlEvents<CSipPhoneControl>,
public IDispatchImpl<ISipPhoneControl, &IID_ISipPhoneControl, &LIBID_EasemobPhoneLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
现在我在 另外一个程序中可以正常调用它,如:
HRESULT hr;
::CoInitialize(NULL);
hr = ::CoCreateInstance(CLSID_SipPhoneControl, NULL, CLSCTX_LOCAL_SERVER, IID_ISipPhoneControl, (void**)&pSipPhoneControl);
if (SUCCEEDED(hr))
{
现在我的问题是 ,我要在这个 ATL exe 中调用这个对象,
直接 new 报错
CSipPhoneControl * pControl = CSipPhoneControl();
报错 :
IntelliSense: a cast to abstract class "CSipPhoneControl" is not allowed:
function "CSipPhoneControl::AddRef" is a pure virtual function
function "CSipPhoneControl::Release" is a pure virtual function
function "CSipPhoneControl::QueryInterface" is a pure virtual function
我的问题是在 ATL exe 中调用这个对象有什么办法吗 ,难道也必须使用 CoCreateInstance 调用吗 ?