如何实现将 _Recordset ** 参数发送到 COM+应用
我有一个 COM+ VB6 应用程序,我使用 MIDL 编译器生成了一个头文件。 标头包含以下定义:
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Gett(
/* [in] */ BSTR sPostCode,
/* [in] */ BSTR sSurname,
/* [retval][out] */ _Recordset **__MIDL_0012) = 0;
在调用此 ive 导入的 C++ 客户端调用中,
#import "C:\Program files\Common Files\System\Ado\msado15.dll"
rename("EOF", "ADOEOF")
然后按如下方式调用 GetAddress 函数:
void AddressLookup::GetAddress(_bstr_t postCode, _bstr_t address)
{
ADODB::_RecordsetPtr recordset;
HRESULT hr = recordset.CreateInstance(__uuidof(ADODB::Recordset));
m_pIAddressLookup->Gett(postCode, address, recordset);
}
但我不断收到此编译器错误:
AddressLookup.cpp(20):错误 C2664: '_AddressLookup::Gett' : 不能 将参数 3 转换为 'ADODB::_RecordsetPtr' 到 '_Recordset ** ' 没有可用的用户定义转换运算符可以执行 此转换或运算符 无法调用
I have a COM+ VB6 application, I generated a header file using the MIDL compiler.
The header contains the following definition:
virtual /* [id] */ HRESULT STDMETHODCALLTYPE Gett(
/* [in] */ BSTR sPostCode,
/* [in] */ BSTR sSurname,
/* [retval][out] */ _Recordset **__MIDL_0012) = 0;
In my c++ client call that calls this ive imported
#import "C:\Program files\Common Files\System\Ado\msado15.dll"
rename("EOF", "ADOEOF")
The GetAddress function is then being called as follows:
void AddressLookup::GetAddress(_bstr_t postCode, _bstr_t address)
{
ADODB::_RecordsetPtr recordset;
HRESULT hr = recordset.CreateInstance(__uuidof(ADODB::Recordset));
m_pIAddressLookup->Gett(postCode, address, recordset);
}
but i keep geting this compiler error:
AddressLookup.cpp(20) : error C2664:
'_AddressLookup::Gett' : cannot
convert parameter 3 from
'ADODB::_RecordsetPtr' to '_Recordset
** '
No user-defined-conversion operator available that can perform
this conversion, or the operator
cannot be called
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这:
应该是
(注意
recordset
前面的&
- 这意味着“获取地址” - 如果您显然使用智能指针,这将调用重载operator&()
这将为您提供存储在智能指针内的接口指针的地址。This:
should be
(note
&
in front ofrecordset
- it means "take address of" - in case of the smart pointer you're obviously using this will call overloadedoperator&()
and this will give you the address of the interface pointer stored inside the smart pointer).