Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum VarEnum
SerializableAttribute 
ComVisibleAttribute(true) 
public enum VarEnum

 Member nameDescription
Supported by the .NET Compact FrameworkVT_ARRAYIndicates a SAFEARRAY pointer. 
Supported by the .NET Compact FrameworkVT_BLOBIndicates length prefixed bytes. 
Supported by the .NET Compact FrameworkVT_BLOB_OBJECTIndicates that a blob contains an object. 
Supported by the .NET Compact FrameworkVT_BOOLIndicates a Boolean value. 
Supported by the .NET Compact FrameworkVT_BSTRIndicates a BSTR string. 
Supported by the .NET Compact FrameworkVT_BYREFIndicates that a value is a reference. 
Supported by the .NET Compact FrameworkVT_CARRAYIndicates a C style array. 
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_CYIndicates a currency value. 
Supported by the .NET Compact FrameworkVT_DATEIndicates a DATE value. 
Supported by the .NET Compact FrameworkVT_DECIMALIndicates a decimal value. 
Supported by the .NET Compact FrameworkVT_DISPATCHIndicates an IDispatch pointer. 
Supported by the .NET Compact FrameworkVT_EMPTYIndicates that a value was not specified. 
Supported by the .NET Compact FrameworkVT_ERRORIndicates an SCODE. 
Supported by the .NET Compact FrameworkVT_FILETIMEIndicates a FILETIME value. 
Supported by the .NET Compact FrameworkVT_HRESULTIndicates an HRESULT. 
Supported by the .NET Compact FrameworkVT_I1Indicates a char value. 
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_I8Indicates a 64-bit integer. 
Supported by the .NET Compact FrameworkVT_INTIndicates an integer value. 
Supported by the .NET Compact FrameworkVT_LPSTRIndicates a null-terminated string. 
Supported by the .NET Compact FrameworkVT_LPWSTRIndicates a wide string terminated by a null reference (Nothing in Visual Basic). 
Supported by the .NET Compact FrameworkVT_NULLIndicates a null value, similar to a null value in SQL. 
Supported by the .NET Compact FrameworkVT_PTRIndicates a pointer type. 
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_RECORDIndicates a user defined type. 
Supported by the .NET Compact FrameworkVT_SAFEARRAYIndicates a SAFEARRAY. Not valid in a VARIANT. 
Supported by the .NET Compact FrameworkVT_STORAGEIndicates that the name of a storage follows. 
Supported by the .NET Compact FrameworkVT_STORED_OBJECTIndicates that a storage contains an object. 
Supported by the .NET Compact FrameworkVT_STREAMIndicates that the name of a stream follows. 
Supported by the .NET Compact FrameworkVT_STREAMED_OBJECTIndicates that a stream contains an object. 
Supported by the .NET Compact FrameworkVT_UI1Indicates a byte
Supported by the .NET Compact FrameworkVT_UI2Indicates an unsignedshort
Supported by the .NET Compact FrameworkVT_UI4Indicates an unsignedlong
Supported by the .NET Compact FrameworkVT_UI8Indicates an 64-bit unsigned integer. 
Supported by the .NET Compact FrameworkVT_UINTIndicates an unsigned integer value. 
Supported by the .NET Compact FrameworkVT_UNKNOWNIndicates an IUnknown pointer. 
Supported by the .NET Compact FrameworkVT_USERDEFINEDIndicates a user defined type. 
Supported by the .NET Compact FrameworkVT_VARIANTIndicates a VARIANT far pointer. 
Supported by the .NET Compact FrameworkVT_VECTORIndicates a simple, counted array. 
Supported by the .NET Compact FrameworkVT_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;
		}
	}
}

import System.*;
import 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.
    // [
    // 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.
    /** @attribute ComImport()
     */
    /** @attribute Guid("73EB4AF8-BE9C-4b49-B3A4-24F4FF657B26")
     */
   public interface IMyStorage
   {
        /** @attribute DispId(1)
         */
        Object GetItem(
        /** @attribute In()
            @attribute MarshalAs(UnmanagedType.BStr)
         */String bstrName);
      
      
        /** @attribute DispId(2)
         */
        void GetItems(
        /** @attribute In()
            @attribute MarshalAs(UnmanagedType.BStr)
         */String bstrLocation,
        /** @attribute Out()
            @attribute MarshalAs(UnmanagedType.SafeArray, 
            SafeArraySubType = VarEnum.VT_VARIANT)
         */Object Items[]);
             
        /** @attribute DispId(3)
         */
        void GetItemDescriptions(
            /** @attribute In()
             */String bstrLocation,
            /** @attribute In()
                @attribute Out()
                @attribute MarshalAs(UnmanagedType.SafeArray)
             */Object varDescriptions[]);
               
        /** @attribute DispId(4)
         */
        /** @return MarshalAs(UnmanagedType.VariantBool)
         */
        boolean get_IsEmpty();
    } //IMyStorage

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

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

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

Community Additions

Show:
© 2014 Microsoft