C++ COM-Object with COM-Object as parameter 
Author Message
 C++ COM-Object with COM-Object as parameter

Hi,
i'm new in programming COM-objects and it would be very nice if someone
could help me with the following problem.
I have to create an COM-object in C++ and the Interface has to be able
to get an COM-object as parameter.
Is it possible to do this and if yes how would be the syntax?

Thanks in advance
Markus

Sent via Deja.com
http://www.*-*-*.com/



Mon, 07 Jul 2003 15:51:48 GMT  
 C++ COM-Object with COM-Object as parameter

Quote:

> Hi,
> i'm new in programming COM-objects and it would be very nice if
someone
> could help me with the following problem.
> I have to create an COM-object in C++ and the Interface has to be able
> to get an COM-object as parameter.
> Is it possible to do this and if yes how would be the syntax?

> Thanks in advance
> Markus>

Hi, there.
It's easy - every COM interface is derived from IUnknown, so
just pass IUnknown* of any COM object and inside the interface
function do QueryInterface(....). BTW, don't forget AddRef() and
Release().

Regards.

Sent via Deja.com
http://www.deja.com/



Tue, 08 Jul 2003 20:53:54 GMT  
 C++ COM-Object with COM-Object as parameter

Quote:
> Hi, there.
> It's easy - every COM interface is derived from IUnknown, so
> just pass IUnknown* of any COM object and inside the interface
> function do QueryInterface(....). BTW, don't forget AddRef() and
> Release().

> Regards.

> Sent via Deja.com
> http://www.deja.com/

Thanks very much.
I have to use the typ VARIANT because i need the COM-Object in a
VBScript application.

e.g. testmethod(VARIANT* objectVar)

Do you know how to get out the IUnknown* - Interface out of objectVar?

Markus

Sent via Deja.com
http://www.deja.com/



Fri, 11 Jul 2003 17:24:29 GMT  
 C++ COM-Object with COM-Object as parameter
IUnknown *pUnk;

if( objectVar.vt == VT_UNKNOWN )
    pUnk = objectVar.punkVal;
else if( objectVar.vt == VT_UNKOWN | VT_BYREF )
    pUnk = *objectVar.ppunkVal;
else
    cerr << "Not an IUnknown Object"


Quote:

> > Hi, there.
> > It's easy - every COM interface is derived from IUnknown, so
> > just pass IUnknown* of any COM object and inside the interface
> > function do QueryInterface(....). BTW, don't forget AddRef() and
> > Release().

> > Regards.

> > Sent via Deja.com
> > http://www.deja.com/

> Thanks very much.
> I have to use the typ VARIANT because i need the COM-Object in a
> VBScript application.

> e.g. testmethod(VARIANT* objectVar)

> Do you know how to get out the IUnknown* - Interface out of objectVar?

> Markus

> Sent via Deja.com
> http://www.deja.com/



Fri, 11 Jul 2003 21:16:04 GMT  
 C++ COM-Object with COM-Object as parameter


Quote:
> IUnknown *pUnk;

> if( objectVar.vt == VT_UNKNOWN )
>     pUnk = objectVar.punkVal;
> else if( objectVar.vt == VT_UNKOWN | VT_BYREF )
>     pUnk = *objectVar.ppunkVal;
> else
>     cerr << "Not an IUnknown Object"

Thanks yery much, i tried it and i works very fine in one way
i made it to instantiate a com-object inside my c++ com-object-server
and return it to VB-Script - Client ... works very well

But i still have a problem:
I have to return the object again to the server:
e.g.
<...>
  Set firstObject=CreateObject("Myfirst.first")

  Dim secondObject
  set secondObject = firstObject.someFunction(...)
  ' i return the secondObject from my C++ Server
  ' with variant-type VT_UNKNOWN set

  secondObject.testmethod(...) 'works fine

  firstObject.someMethod(secondObject)
  'my C++ COM-Server gets the Object with VT_IDISPATCH set --> why ???
<...>

Is there a problem if i ignore the VT_IDISPATCH Type and just handle it
as normal VT_IUNKNOWN or do i have to do something like Invoke?

Thanks Markus

Sent via Deja.com
http://www.deja.com/



Sun, 13 Jul 2003 05:46:04 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Passing COM objects as parameters to other COM objects

2. Passing COM objects as parameters to other COM objects

3. Return a pointer to a nested COM object from a COM object method

4. Invoking COM object from COM object

5. passing COM object pointers to another COM object in ATL

6. COM Object returning COM Object Reference

7. COM object in a COM object

8. Creating COM objects from COM objects

9. Problem with scripting context when using VB com object inside VC com object

10. Using COM objects within COM objects

11. Passing an Excel COM object to a C++ COM Server

12. Call Com objects inside c++ object

 

 
Powered by phpBB® Forum Software