Expand Minimize

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 the .NET Compact FrameworkVT_EMPTYIndicates that a value was not specified.
Supported by the .NET Compact FrameworkVT_NULLIndicates a null value, similar to a null value in SQL.
Supported by the .NET Compact FrameworkVT_I2Indicates a short integer.
Supported by the .NET Compact FrameworkVT_I4Indicates a long integer.
Supported by the .NET Compact FrameworkVT_R4Indicates a float value.
Supported by the .NET Compact FrameworkVT_R8Indicates a double value.
Supported by the .NET Compact FrameworkVT_CYIndicates a currency value.
Supported by the .NET Compact FrameworkVT_DATEIndicates a DATE value.
Supported by the .NET Compact FrameworkVT_BSTRIndicates a BSTR string.
Supported by the .NET Compact FrameworkVT_DISPATCHIndicates an IDispatch pointer.
Supported by the .NET Compact FrameworkVT_ERRORIndicates an SCODE.
Supported by the .NET Compact FrameworkVT_BOOLIndicates a Boolean value.
Supported by the .NET Compact FrameworkVT_VARIANTIndicates a VARIANT far pointer.
Supported by the .NET Compact FrameworkVT_UNKNOWNIndicates an IUnknown pointer.
Supported by the .NET Compact FrameworkVT_DECIMALIndicates a decimal value.
Supported by the .NET Compact FrameworkVT_I1Indicates a char value.
Supported by the .NET Compact FrameworkVT_UI1Indicates a byte.
Supported by the .NET Compact FrameworkVT_UI2Indicates an unsigned short.
Supported by the .NET Compact FrameworkVT_UI4Indicates an unsigned long.
Supported by the .NET Compact FrameworkVT_I8Indicates a 64-bit integer.
Supported by the .NET Compact FrameworkVT_UI8Indicates an 64-bit unsigned integer.
Supported by the .NET Compact FrameworkVT_INTIndicates an integer value.
Supported by the .NET Compact FrameworkVT_UINTIndicates an unsigned integer value.
Supported by the .NET Compact FrameworkVT_VOIDIndicates a C style void.
Supported by the .NET Compact FrameworkVT_HRESULTIndicates an HRESULT.
Supported by the .NET Compact FrameworkVT_PTRIndicates a pointer type.
Supported by the .NET Compact FrameworkVT_SAFEARRAYIndicates a SAFEARRAY. Not valid in a VARIANT.
Supported by the .NET Compact FrameworkVT_CARRAYIndicates a C style array.
Supported by the .NET Compact FrameworkVT_USERDEFINEDIndicates a user defined type.
Supported by the .NET Compact FrameworkVT_LPSTRIndicates a null-terminated string.
Supported by the .NET Compact FrameworkVT_LPWSTRIndicates a wide string terminated by null.
Supported by the .NET Compact FrameworkVT_RECORDIndicates a user defined type.
Supported by the .NET Compact FrameworkVT_FILETIMEIndicates a FILETIME value.
Supported by the .NET Compact FrameworkVT_BLOBIndicates length prefixed bytes.
Supported by the .NET Compact FrameworkVT_STREAMIndicates that the name of a stream follows.
Supported by the .NET Compact FrameworkVT_STORAGEIndicates that the name of a storage follows.
Supported by the .NET Compact FrameworkVT_STREAMED_OBJECTIndicates that a stream contains an object.
Supported by the .NET Compact FrameworkVT_STORED_OBJECTIndicates that a storage contains an object.
Supported by the .NET Compact FrameworkVT_BLOB_OBJECTIndicates that a blob contains an object.
Supported by the .NET Compact FrameworkVT_CFIndicates the clipboard format.
Supported by the .NET Compact FrameworkVT_CLSIDIndicates a class ID.
Supported by the .NET Compact FrameworkVT_VECTORIndicates a simple, counted array.
Supported by the .NET Compact FrameworkVT_ARRAYIndicates a SAFEARRAY pointer.
Supported by the .NET Compact FrameworkVT_BYREFIndicates that a value is a reference.

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;
		}
	}
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

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

.NET Framework

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

.NET Compact Framework

Supported in: 3.5, 2.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft