Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

_com_ptr_t vs. CComPtr variant_t vs. CComVariant

314 views
Skip to first unread message

Sergey Karpov

unread,
Oct 8, 2002, 4:10:02 PM10/8/02
to
Hi guys,

I see that MS provides two sets of COM wrappers. One comes packaged with
nice language extensions #import "..." _com_ptr_t, _bstr_t & _varaint_t.
Another one is coming with ATL CComPtr, CComVariant, etc. ATL also is nice
and accompanied with several wizards (with several bugs). I found that
these COM's wrappers are colliding at least in my case. I am working with
MSXML.

When I use #import I getting proxy signature for XMLDocument.async like
put_asunc(short ....)

when I use #include <msxml2.h> I get proxy signature like:

put_asunc(VARIANT ....) ; The question is:

How will be proxy code generated?

I believe MIDL in both cases will generate code based on msxml2.IDL and IDL
uses VARIANTs.

Where #import"" gets information about real data-tpyes for parameters?

What are MS guide lines for using #import and ATL?

-SKV


Jian-Shen Lin[MS]

unread,
Oct 10, 2002, 11:15:27 PM10/10/02
to
The #import directive is used to incorporate information from a type
library. The content of the type library is converted into C++ classes,
mostly describing the COM interfaces.

You can use #import can optionally include one or more attributes. These
attributes tell the compiler to modify the contents of the type-library
headers.

CComPtr Class provider a smart pointer class for managing COM interface
pointers.
If you don't use ATL, you can use C++ com wrapper class, _com_ptr_t object
encapsulates a COM interface pointer and is called a "smart" pointer.
A smart pointer is usually referenced by the typedef definition provided by
the _COM_SMARTPTR_TYPEDEF macro. This macro takes an interface name and the
IID and declares a specialization of _com_ptr_t with the name of the
interface plus a suffix of Ptr. For example:

_COM_SMARTPTR_TYPEDEF(IMyInterface | __uuidof(IMyInterface));
declares the _com_ptr_t specialization IMyInterfacePtr.

Best Regards

Jian Shen

This posting is provided "AS IS" with no warranties, and confers no rights.


0 new messages