简体   繁体   中英

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] */ 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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM