@ -18,6 +18,25 @@ internal struct ComVariant : IDisposable
internal const short VARIANT_TRUE = - 1 ;
internal const short VARIANT_TRUE = - 1 ;
internal const short VARIANT_FALSE = 0 ;
internal const short VARIANT_FALSE = 0 ;
#if DEBUG
static unsafe ComVariant ( )
{
// Variant size is the size of 4 pointers (16 bytes) on a 32-bit processor,
// and 3 pointers (24 bytes) on a 64-bit processor.
// See definition in oaidl.h in the Windows SDK.
int variantSize = sizeof ( ComVariant ) ;
if ( IntPtr . Size = = 4 )
{
Debug . Assert ( variantSize = = ( 4 * IntPtr . Size ) ) ;
}
else
{
Debug . Assert ( IntPtr . Size = = 8 ) ;
Debug . Assert ( variantSize = = ( 3 * IntPtr . Size ) ) ;
}
}
#endif
// Most of the data types in the Variant are carried in _typeUnion
// Most of the data types in the Variant are carried in _typeUnion
[FieldOffset(0)] private TypeUnion _ typeUnion ;
[FieldOffset(0)] private TypeUnion _ typeUnion ;
@ -32,6 +51,13 @@ internal struct ComVariant : IDisposable
public UnionTypes _ unionTypes ;
public UnionTypes _ unionTypes ;
}
}
[StructLayout(LayoutKind.Sequential)]
private struct Record
{
public IntPtr _ record ;
public IntPtr _ recordInfo ;
}
[StructLayout(LayoutKind.Explicit)]
[StructLayout(LayoutKind.Explicit)]
private unsafe struct UnionTypes
private unsafe struct UnionTypes
{
{
@ -56,6 +82,7 @@ internal struct ComVariant : IDisposable
[FieldOffset(0)] public IntPtr _d ispatch ;
[FieldOffset(0)] public IntPtr _d ispatch ;
[FieldOffset(0)] public IntPtr _ pvarVal ;
[FieldOffset(0)] public IntPtr _ pvarVal ;
[FieldOffset(0)] public IntPtr _ byref ;
[FieldOffset(0)] public IntPtr _ byref ;
[FieldOffset(0)] public Record _ record ;
[FieldOffset(0)] public SafeArrayRef parray ;
[FieldOffset(0)] public SafeArrayRef parray ;
[FieldOffset(0)] public SafeArrayRef * pparray ;
[FieldOffset(0)] public SafeArrayRef * pparray ;
}
}