passing COM object pointers to another COM object in ATL 
Author Message
 passing COM object pointers to another COM object in ATL

hi,
I have a COM object having a member pointer variable pointing to a C++
object. I want to create another COM object with a method that accepts
the first COM object as a parameter.

I tried using VARIANT, but the pointer variable in the passed object
comes in as NULL (though, the pointers were initialized before being
passed).

It works fine if I use IUnknown* or IDispatch*; but then I am not able
to use the parameter as "optional" when calling from VB (it throws a
type mismatch if I dont pass an argument to an optional parameter of
type IUnknown* or IDispatch*).

Any ideas why this is happening? Any solutions?



Fri, 04 Jun 2004 19:32:12 GMT  
 passing COM object pointers to another COM object in ATL


Quote:
> hi,
> I have a COM object having a member pointer variable pointing to a C++
> object. I want to create another COM object with a method that accepts
> the first COM object as a parameter.

> I tried using VARIANT, but the pointer variable in the passed object
> comes in as NULL (though, the pointers were initialized before being
> passed).

> It works fine if I use IUnknown* or IDispatch*; but then I am not able
> to use the parameter as "optional" when calling from VB (it throws a
> type mismatch if I dont pass an argument to an optional parameter of
> type IUnknown* or IDispatch*).

> Any ideas why this is happening? Any solutions?



Fri, 18 Jun 2004 13:58:22 GMT  
 passing COM object pointers to another COM object in ATL
So did you store IUnknown or IDispatch in that VARIANT? Did you AddRef
it? Did you set the vartype to VT_UNKNOWN or VT_DISPATCH respectively?

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:



> > hi,
> > I have a COM object having a member pointer variable pointing to a C++
> > object. I want to create another COM object with a method that accepts
> > the first COM object as a parameter.

> > I tried using VARIANT, but the pointer variable in the passed object
> > comes in as NULL (though, the pointers were initialized before being
> > passed).

> > It works fine if I use IUnknown* or IDispatch*; but then I am not able
> > to use the parameter as "optional" when calling from VB (it throws a
> > type mismatch if I dont pass an argument to an optional parameter of
> > type IUnknown* or IDispatch*).

> > Any ideas why this is happening? Any solutions?



Mon, 21 Jun 2004 04:27:49 GMT  
 passing COM object pointers to another COM object in ATL


Fri, 19 Jun 1992 00:00:00 GMT  
 passing COM object pointers to another COM object in ATL
Could you please send me a piece of your code.
I am trying to do the same but I have no sample code

Thank you by advance.



Tue, 22 Jun 2004 04:09:36 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. COM/ATL novice:passing object pointers through methods on a COM interface

2. Passing COM objects as parameters to other COM objects

3. Passing COM objects as parameters to other COM objects

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

5. ATL COM - Passing ATL COM classes through another ATL COM class in the same app

6. Passing a COM object to a non-COM aware class

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

8. Invoking COM object from COM object

9. COM Object returning COM Object Reference

10. COM object in a COM object

11. C++ COM-Object with COM-Object as parameter

12. Creating COM objects from COM objects

 

 
Powered by phpBB® Forum Software