VarEnum Enumeration

Note: This API is now obsolete.

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
Assemblies:   System.Runtime.InteropServices (in System.Runtime.InteropServices.dll)
  mscorlib (in mscorlib.dll)

'Declaration
<ObsoleteAttribute("Marshalling VARIANTs may be unavailable in future releases.")> _
Public Enumeration VarEnum

Member nameDescription
Supported by Portable Class LibraryVT_ARRAYIndicates a SAFEARRAY pointer.
Supported by Portable Class LibraryVT_BLOBIndicates length prefixed bytes.
Supported by Portable Class LibraryVT_BLOB_OBJECTIndicates that a blob contains an object.
Supported by Portable Class LibraryVT_BOOLIndicates a Boolean value.
Supported by Portable Class LibraryVT_BSTRIndicates a BSTR string.
Supported by Portable Class LibraryVT_BYREFIndicates that a value is a reference.
Supported by Portable Class LibraryVT_CARRAYIndicates a C style array.
Supported by Portable Class LibraryVT_CFIndicates the clipboard format.
Supported by Portable Class LibraryVT_CLSIDIndicates a class ID.
Supported by Portable Class LibraryVT_CYIndicates a currency value.
Supported by Portable Class LibraryVT_DATEIndicates a DATE value.
Supported by Portable Class LibraryVT_DECIMALIndicates a decimal value.
Supported by Portable Class LibraryVT_DISPATCHIndicates an IDispatch pointer.
Supported by Portable Class LibraryVT_EMPTYIndicates that a value was not specified.
Supported by Portable Class LibraryVT_ERRORIndicates an SCODE.
Supported by Portable Class LibraryVT_FILETIMEIndicates a FILETIME value.
Supported by Portable Class LibraryVT_HRESULTIndicates an HRESULT.
Supported by Portable Class LibraryVT_I1Indicates a char value.
Supported by Portable Class LibraryVT_I2Indicates a short integer.
Supported by Portable Class LibraryVT_I4Indicates a long integer.
Supported by Portable Class LibraryVT_I8Indicates a 64-bit integer.
Supported by Portable Class LibraryVT_INTIndicates an integer value.
Supported by Portable Class LibraryVT_LPSTRIndicates a null-terminated string.
Supported by Portable Class LibraryVT_LPWSTRIndicates a wide string terminated by Nothing.
Supported by Portable Class LibraryVT_NULLIndicates a null value, similar to a null value in SQL.
Supported by Portable Class LibraryVT_PTRIndicates a pointer type.
Supported by Portable Class LibraryVT_R4Indicates a float value.
Supported by Portable Class LibraryVT_R8Indicates a double value.
Supported by Portable Class LibraryVT_RECORDIndicates a user defined type.
Supported by Portable Class LibraryVT_SAFEARRAYIndicates a SAFEARRAY. Not valid in a VARIANT.
Supported by Portable Class LibraryVT_STORAGEIndicates that the name of a storage follows.
Supported by Portable Class LibraryVT_STORED_OBJECTIndicates that a storage contains an object.
Supported by Portable Class LibraryVT_STREAMIndicates that the name of a stream follows.
Supported by Portable Class LibraryVT_STREAMED_OBJECTIndicates that a stream contains an object.
Supported by Portable Class LibraryVT_UI1Indicates a byte.
Supported by Portable Class LibraryVT_UI2Indicates an unsigned short.
Supported by Portable Class LibraryVT_UI4Indicates an unsigned long.
Supported by Portable Class LibraryVT_UI8Indicates an 64-bit unsigned integer.
Supported by Portable Class LibraryVT_UINTIndicates an unsigned integer value.
Supported by Portable Class LibraryVT_UNKNOWNIndicates an IUnknown pointer.
Supported by Portable Class LibraryVT_USERDEFINEDIndicates a user defined type.
Supported by Portable Class LibraryVT_VARIANTIndicates a VARIANT far pointer.
Supported by Portable Class LibraryVT_VECTORIndicates a simple, counted array.
Supported by Portable Class LibraryVT_VOIDIndicates a C style void.

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

Imports System
Imports System.Runtime.InteropServices

Module MyModule
	' 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. 

	'[ 
	'object, 
	'uuid("73EB4AF8-BE9C-4b49-B3A4-24F4FF657B26"), 
	'dual,	helpstring("IMyStorage Interface"), 
	'pointer_default(unique) 
	'] 
	'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.

	<ComImport(), Guid("73EB4AF8-BE9C-4b49-B3A4-24F4FF657B26")> _
	Public Interface IMyStorage
		<DispId(1)> _
		Function GetItem(<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByVal bstrName As String) _
		   As <MarshalAs(UnmanagedType.Interface)> Object

		<DispId(2)> _
		Function GetItems(<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByVal bstrLocation As String, _
		   <OutAttribute(), MarshalAs(UnmanagedType.SafeArray, SafeArraySubType := VarEnum.VT_VARIANT)> _
                                      ByVal Items() As Object)

		<DispId(3)> _
		Function GetItemDescriptions(<InAttribute()> ByVal bstrLocation As String, _
		   <InAttribute(), OutAttribute(), _
                      MarshalAs(UnmanagedType.SafeArray)> ByRef varDescriptions() As Object)

		<DispId(4)> _
		ReadOnly Property IsEmpty(<MarshalAs(UnmanagedType.VariantBool)> ByVal bEmpty As Boolean)

	End Interface 
End Module

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
Obsolete (compiler warning) in 4.6

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

.NET for Windows Phone apps

Obsolete (compiler warning) in Windows Phone 8.1

Portable Class Library

Supported in: Portable Class Library
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft