描述:
有一个类,要写成COM类型的DLL,我用ATL写
别的函数都正常,最后一个函数的参数是char*,我写上后编译错误
error C2259: 'CComObject<class CEventMatch>' : cannot instantiate abstract class due to following members: c:\program files\microsoft visual studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template member function 'long __stdcall ATL::CComCreator<class ATL::CComObject<class CEventMatch> >::CreateInstance(void *,const struct _GUID &
,void ** )'
IDL文件中声明如下:
HRESULT InitDB(char* ODBCConnstr);//去掉此行正常编译
类中如下:
头:
virtual HRESULT STDMETHODCALLTYPE InitDB2(char* ODBCConnstr);
CPP:
HRESULT CEventMatch::InitDB2(LPCSTR ODBCConnstr)
{
...
请问这个应该如何解决?
解决方案1:
用CHAR试,TCHAR也试
atl中,它可以生d成asni,或unicode
我用的没有问题
用WCHAR
解决方案3:我只知道如果继承与iDispatch,是不可用void *的
解决方案4: HRESULT InitDB(OLECHAR *ODBCConnstr);
注意COM接口都使用宽字符
客户端访问时使用BSTR类型来初始化连接串
::SysAllocString("Provider....")
用完后注意释放
::SysFreeString();
参数换成BSTR