Platform SDK: Automation

BSTR and Vector Conversion Functions

Automation supports conversion between an array of bytes and a BSTR through the two low-level conversion functions VectorFromBstr and BstrFromVector, and by performing the appropriate conversions in VariantChangeType, ITypeInfo::Invoke, DispInvoke, and other relevant locations.

BSTRs are wide, double-byte (Unicode) strings on 32-bit Windows platforms, and narrow, single-byte strings on 16-bit Windows and the Apple PowerMac. These functions do not perform any special string handling. They simply move bytes from one location to another, so the width of strings does not affect these API functions.

BSTR and Vector Conversion Functions Descriptions
VectorFromBstr Returns a vector, assigning each character in the BSTR to an element of the vector.
BstrFromVector Returns a BSTR, assigning each element of the vector to a character in the BSTR.

Note  If these functions are passed NULL pointers then there will be an access violation and the program will crash. It is your responsibility to protect these functions against NULL pointers.