Visual C++ Native COM Support [Previous] [Next]

Visual C++ Native COM Support

Ever since the 5.0 release, Visual C++ has provided several COM helper classes as part of its run-time library. These classes—including _com_ptr_t, _bstr_t, and _variant_t—provide support similar to the CComPtr, CComBSTR, and CComVariant classes described in this chapter. How do you decide whether to use the run-time classes or the C++ classes? Both sets of classes perform nearly identically, with a few exceptions:

Neither set of classes is clearly preferable, so the decision is up to you. It's likely that Microsoft will continue to support both sets of classes for some time. In fact, you can use both the run-time classes and the ATL client classes in a single application. For fairly obvious reasons, however, we recommend using the run-time classes from within MFC applications and the ATL classes within an ATL project.