Here is a sample to create an array of BSTR’s…
[sourcecode language=’cpp’]const long lCount = 100;
_bstr_t bstrArray[lCount];
COleSafeArray cosaSafeArray;
cosaSafeArray.CreateOneDim( VT_BSTR, lCount )
// Fill out this array
for( long lIndex = 0; lIndex < lCount; ++lIndex )
{
cosaSafeArray.PutElement( &lIndex,
static_cast
}
// Now you have a safe array of bstr’s and since COleSafeArray
// is inherited from VARIANT you can directly use this safearray
// in COM calls with no overhead for freeing safe array[/sourcecode]
Thank you for this simple info…really helped!
Nice to hear that 🙂
Good method man.!
🙂
Hey Ajay, nice to read your comment, Thanks!
Use CComSafeArray instead as it exists in ATL and don’t require MFC.