This documentation is archived and is not being maintained.

VarEnum Enumeration

Indicates how to marshal the array elements when an array is marshaled from managed to unmanaged code as a UnmanagedType::SafeArray.

Namespace:  System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

public enum class VarEnum

Member nameDescription
VT_EMPTYIndicates that a value was not specified.
VT_NULLIndicates a null value, similar to a null value in SQL.
VT_I2Indicates a short integer.
VT_I4Indicates a long integer.
VT_R4Indicates a float value.
VT_R8Indicates a double value.
VT_CYIndicates a currency value.
VT_DATEIndicates a DATE value.
VT_BSTRIndicates a BSTR string.
VT_DISPATCHIndicates an IDispatch pointer.
VT_ERRORIndicates an SCODE.
VT_BOOLIndicates a Boolean value.
VT_VARIANTIndicates a VARIANT far pointer.
VT_UNKNOWNIndicates an IUnknown pointer.
VT_DECIMALIndicates a decimal value.
VT_I1Indicates a char value.
VT_UI1Indicates a byte.
VT_UI2Indicates an unsigned short.
VT_UI4Indicates an unsigned long.
VT_I8Indicates a 64-bit integer.
VT_UI8Indicates an 64-bit unsigned integer.
VT_INTIndicates an integer value.
VT_UINTIndicates an unsigned integer value.
VT_VOIDIndicates a C style void.
VT_PTRIndicates a pointer type.
VT_SAFEARRAYIndicates a SAFEARRAY. Not valid in a VARIANT.
VT_CARRAYIndicates a C style array.
VT_USERDEFINEDIndicates a user defined type.
VT_LPSTRIndicates a null-terminated string.
VT_LPWSTRIndicates a wide string terminated by nullptr.
VT_RECORDIndicates a user defined type.
VT_FILETIMEIndicates a FILETIME value.
VT_BLOBIndicates length prefixed bytes.
VT_STREAMIndicates that the name of a stream follows.
VT_STORAGEIndicates that the name of a storage follows.
VT_STREAMED_OBJECTIndicates that a stream contains an object.
VT_STORED_OBJECTIndicates that a storage contains an object.
VT_BLOB_OBJECTIndicates that a blob contains an object.
VT_CFIndicates the clipboard format.
VT_CLSIDIndicates a class ID.
VT_VECTORIndicates a simple, counted array.
VT_ARRAYIndicates a SAFEARRAY pointer.
VT_BYREFIndicates that a value is a reference.

Used with System.Runtime.InteropServices::MarshalAsAttribute to explicitly control the element type of the SafeArray.

using namespace System;
using namespace System::Runtime::InteropServices;

// If you do not have a type library for an interface
// you can redeclare it using ComImportAttribute.
// This is how the interface would look in an idl file.
//dual, helpstring("IMyStorage Interface"),
//interface IMyStorage : IDispatch
// [id(1)]
// HRESULT GetItem([in] BSTR bstrName, [out, retval] IDispatch ** ppItem);
// [id(2)]
// HRESULT GetItems([in] BSTR bstrLocation, [out] SAFEARRAY(VARIANT)* pItems);
// [id(3)]
// HRESULT GetItemDescriptions([in] BSTR bstrLocation, [out] SAFEARRAY(VARIANT) ** ppItems);
// [id(4), propget]
// HRESULT get_IsEmpty([out, retval] BOOL * pfEmpty);
// This is the managed declaration.

interface class IMyStorage
   Object^ GetItem( [In,MarshalAs(UnmanagedType::BStr)]String^ bstrName );

   //[return : MarshalAs(UnmanagedType::Interface)]

   void GetItems( [In,MarshalAs(UnmanagedType::BStr)]String^ bstrLocation, [Out,MarshalAs(UnmanagedType::SafeArray,
   SafeArraySubType=VarEnum::VT_VARIANT)]array<Object^>^Items );

   void GetItemDescriptions( [In]String^ bstrLocation, [In,Out,MarshalAs(UnmanagedType::SafeArray)]array<Object^>^varDescriptions );

   property bool IsEmpty 
      bool get();

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.