So BSTRs have memory management rules which need to be observed otherwise one will leak memory. Thankfully C++ classes using RAII design patterns can assist. It just seems there are more than one to choose from and it is worth documenting them here on a blog entry.
| BSTR helper classes | Vendor | Library | Header |
|---|---|---|---|
| _bstr_t Class | Microsoft | Native C++ compiler COM support | comutil.h |
| CComBSTR Class | Microsoft | ATL | atlbase.h |
Variant also has helper classes
| Variant helper classes | Vendor | Library | Header |
|---|---|---|---|
| _variant_t Class | Microsoft | Native C++ compiler COM support | comutil.h |
| CComVariant Class | Microsoft | ATL | atlbase.h |
Also found a nice page of sample code demonstrating the Native C++ compiler COM support classes interacting with ADO objects which are normally scripted with VBA and thus have automation-typed interfaces. Visual C++ ADO Programming
Also Stack Overflow question discussing the classes available. Looks like the classes listed above represent the sum of Microsoft options.
No comments:
Post a Comment