Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How is a COM object passed as a parameter to another COM Object?

Status
Not open for further replies.

abramowi

Technical User
Joined
May 2, 2003
Messages
10
Location
GB
Hi!

I have created a COM object in C++ called Collection.

I now want to pass this Collection as a parameter to another COM object. How do I specify that in the IDL and how do I access that the Collection objects parameters in the new object?

Thank you in advance /Dave
 
Dave, welcome to Tek-Tips [cheers]

for IDispatch interfaces use VARIANT
Code:
[in] VARIANT

for custom interfaces use a pointer to the interface
Code:
[in] *IMyInterface


-pete
I just can't seem to get back my IntelliSense
 
>>for IDispatch interfaces use VARIANT

Why not just use LPDispatch ?


Greetings,
Rick
 
Thanks for the quick replies guys...

Once I have received the Collection COM object to my new COM object (I guess it is actually the IDispatch interface I am receiving, right?)

How do I access the COM Collection object's functions in VC++? Do I simply cast it to an IDispatch* interface or something?

Thanks /Dave
 
Opps, forgot to mention:

By casting i mean to execute a QueryInterface (if you're NOT using smartpointers).


Greetings,
Rick
 
ERROR!

I thought everything was working fine, when I implemented the COM method using my COM Collection as described below:

STDMETHODIMP CAPIFactory::insertCollection(IUnknown* coll)
{
// TODO: Add your implementation code here

CComPtr<ICollection> pI;
coll->QueryInterface(__uuidof(CCollection), (void **) &pI);

return S_OK;
}

And when I compile the class it works fine... But then when I build the whole project I get the following errors:

COMCTAPI error LNK2001: unresolved external symbol &quot;public: virtual long __stdcall CCollection::Keys(struct tagVARIANT *)&quot; (?Keys@CCollection@@UAGJPAUtagVARIANT@@@Z)

COMCTAPI error LNK2001: unresolved external symbol &quot;public: virtual long __stdcall CCollection::Get(unsigned short *,unsigned short * *)&quot; (?Get@CCollection@@UAGJPAGPAPAG@Z)

COMCTAPI error LNK2001: unresolved external symbol &quot;public: virtual long __stdcall CCollection::Remove(unsigned short *)&quot; (?Remove@CCollection@@UAGJPAG@Z)

COMCTAPI error LNK2001: unresolved external symbol &quot;public: virtual long __stdcall CCollection::Add(unsigned short *,unsigned short *)&quot; (?Add@CCollection@@UAGJPAG0@Z)

Where the function Keys, Get, Remove and Add are the methods in the COM object Collection.

What am I doing wrong? (I have stated #include &quot;../COMCTCollection/Collection.h&quot; in the cpp file)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top