GTAVLover GTAVLover - 3 years ago 62
C++ Question

COM Automation structures vs wrappers for them

I am developing a COM wrapper for Windows APIs, which can be used from scripting languages those don't have native Windows API support. So I am thinking about what should I use in COM ATL projects.

SAFEARRAY
or
CComSafeArray
?
VARIANT
or
CComVariant
? Or any other structure or the appropriate wrapper for it?

I tested using both types, but no any special performance differences, usage problems or additional implementations found between them.

Which one is the best to be used in COM ATL projects? For example,
SAFEARRAY
or
CComSafeArray
?

Answer Source

The interfaces and coclasses MUST use SAFEARRAY and VARIANT. You can't have a COM interface or object that uses a CComSafeArray or CComVariant in any of their COM-public method signatures or properties. You can use CComSafeArray or CComVariant inside the coclass implementations, however.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download