Export (0) Print
Expand All

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)

[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum VarEnum

Member nameDescription
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_ARRAYIndicates a SAFEARRAY pointer.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_BLOBIndicates length prefixed bytes.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_BLOB_OBJECTIndicates that a blob contains an object.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_BOOLIndicates a Boolean value.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_BSTRIndicates a BSTR string.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_BYREFIndicates that a value is a reference.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_CARRAYIndicates a C style array.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_CFIndicates the clipboard format.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_CLSIDIndicates a class ID.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_CYIndicates a currency value.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_DATEIndicates a DATE value.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_DECIMALIndicates a decimal value.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_DISPATCHIndicates an IDispatch pointer.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_EMPTYIndicates that a value was not specified.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_ERRORIndicates an SCODE.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_FILETIMEIndicates a FILETIME value.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_HRESULTIndicates an HRESULT.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_I1Indicates a char value.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_I2Indicates a short integer.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_I4Indicates a long integer.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_I8Indicates a 64-bit integer.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_INTIndicates an integer value.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_LPSTRIndicates a null-terminated string.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_LPWSTRIndicates a wide string terminated by null.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_NULLIndicates a null value, similar to a null value in SQL.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_PTRIndicates a pointer type.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_R4Indicates a float value.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_R8Indicates a double value.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_RECORDIndicates a user defined type.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_SAFEARRAYIndicates a SAFEARRAY. Not valid in a VARIANT.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_STORAGEIndicates that the name of a storage follows.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_STORED_OBJECTIndicates that a storage contains an object.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_STREAMIndicates that the name of a stream follows.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_STREAMED_OBJECTIndicates that a stream contains an object.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_UI1Indicates a byte.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_UI2Indicates an unsigned short.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_UI4Indicates an unsigned long.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_UI8Indicates an 64-bit unsigned integer.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_UINTIndicates an unsigned integer value.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_UNKNOWNIndicates an IUnknown pointer.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_USERDEFINEDIndicates a user defined type.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_VARIANTIndicates a VARIANT far pointer.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_VECTORIndicates a simple, counted array.
Supported by Portable Class LibrarySupported in .NET for Windows Store appsVT_VOIDIndicates a C style void.

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

using System;
using System.Runtime.InteropServices;

namespace 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)]
		[return : MarshalAs( UnmanagedType.Interface )]
		Object GetItem( [In, MarshalAs( UnmanagedType.BStr )] String bstrName );

		[DispId(2)]
		void GetItems( [In, MarshalAs( UnmanagedType.BStr )] String bstrLocation, 
			[Out, MarshalAs( UnmanagedType.SafeArray, 
					  SafeArraySubType = VarEnum.VT_VARIANT )] out Object[] Items );


		[DispId(3)]
		void GetItemDescriptions( [In] String bstrLocation, 
			[In, Out, MarshalAs( UnmanagedType.SafeArray )] ref Object[] varDescriptions );

		bool IsEmpty 
		{
			[DispId(4)]
			[return : MarshalAs( UnmanagedType.VariantBool )]
			get;
		}
	}
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Obsolete (compiler warning) in Windows Phone 8.1

Windows Phone 8.1, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft