How do I implement sending a _Recordset ** parameter to a COM+ application
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] */ BS开发者_运维问答TR 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
This:
m_pIAddressLookup->Gett(postCode, address, recordset);
should be
m_pIAddressLookup->Gett(postCode, address, &recordset);
(note &
in front of recordset
- it means "take address of" - in case of the smart pointer you're obviously using this will call overloaded operator&()
and this will give you the address of the interface pointer stored inside the smart pointer).
精彩评论