The marshalling of most base data types is generally straightforward with the exception of ELEMENT_TYPE_BOOL and ELEMENT_TYPE_CHAR data types. The Boolean type can be marshaled to one of two possible representations. Typically Boolean types are marshaled to a 2-byte integer value where the value 1 represents TRUE and 0 represents FALSE. This representation is identified by UnmanageType.Bool. The other representation is commonly used by Visual Basic. UnmanageType.VariantBool is a 4-byte integer value where the value –1 represents TRUE and 0 represents FALSE.
The marshaling options for ELEMENT_TYPE_BOOL are as follows:
Unmanaged Type | Description of unmanaged format |
---|---|
UnmanagedType.Bool (P/Invoke) | a 2-byte integer value where the value 1 represents TRUE and 0 represents FALSE. |
UnmanagedType.VariantBool (COM) | 4-byte integer value where the value –1 represents TRUE and 0 represents FALSE |
Table 5 - Marshaling Options for booleans