How to create SafeArray of BSTR’s?

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( bstrArray[lIndex] ); } // Now you have a safe array of bstr’s and since […]
Continue reading…

 

Creating SafeArray of bytes.

How to create a safearray of bytes… [sourcecode language=’cpp’]// An array having some data unsigned char ucBytes[2048];  // Create ole safe array object  COleSafeArray cosaByteArray; // Copy bytes to safe array cosaByteArray.CreateOneDim( VT_UI1, sizeof( ucBytes ), ucBytes ); // Get safe array in variant form _variant_t vtByteArray = cosaByteArray.Detach();[/sourcecode]
Continue reading…