What Are the Variant, SafeArray, and BSTR Data TypesPrimary Software: LabWindows/CVI Development Systems>>Full Development SystemPrimary Software Version: 8.1.1 Primary Software Fixed Version: N/A Secondary Software: LabVIEW Development Systems>>LabVIEW Professional Development System
Problem: What is a Variant data type? What is a SafeArray data type? What is a BSTR data type? Why are these needed? Solution: You will come across these data types frequently when communicating via ActiveX/COM. A "Variant" is essentially a universal data type. It can contain any kind of information internally (i.e., it can represent any data type), along with some information about what data type the information belongs to; it is a general purpose, package data type. Think of a Variant as something that can represent every possible data type, but it separates the data itself the type information into individual pieces of the "package". A BSTR is a basic string type that is simply another method for storing character string information (different than a NULL-terminated ASCII string). A BSTR stores characters in a UNICODE format. The first two bytes in the BSTR represent the length of the string. The actual data string comes after these first two bytes. Finally, a SafeArray is an array type that contains user-protection information, together with the actual data. Think of a SafeArray as a normal C array, but it has additional information on the size of the array (i.e., the number of elements in the array) included in the actual data structure. For additional information, refer to the attached Word document.
Report Date: 05/06/1998 Last Updated: 09/28/2007 Document ID: DIRECT-3U8U26 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
