Upraviť

Zdieľať cez


VarEnum Enum

Definition

Caution

Marshalling VARIANTs may be unavailable in future releases.

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

public enum class VarEnum
[System.Obsolete("Marshalling VARIANTs may be unavailable in future releases.")]
public enum VarEnum
public enum VarEnum
[System.Serializable]
public enum VarEnum
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum VarEnum
[<System.Obsolete("Marshalling VARIANTs may be unavailable in future releases.")>]
type VarEnum = 
type VarEnum = 
[<System.Serializable>]
type VarEnum = 
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type VarEnum = 
Public Enum VarEnum
Inheritance
Attributes

Fields

Name Value Description
VT_EMPTY 0

Indicates that a value was not specified.

VT_NULL 1

Indicates a null value, similar to a null value in SQL.

VT_I2 2

Indicates a short integer.

VT_I4 3

Indicates a long integer.

VT_R4 4

Indicates a float value.

VT_R8 5

Indicates a double value.

VT_CY 6

Indicates a currency value.

VT_DATE 7

Indicates a DATE value.

VT_BSTR 8

Indicates a BSTR string.

VT_DISPATCH 9

Indicates an IDispatch pointer.

VT_ERROR 10

Indicates an SCODE.

VT_BOOL 11

Indicates a Boolean value.

VT_VARIANT 12

Indicates a VARIANT far pointer.

VT_UNKNOWN 13

Indicates an IUnknown pointer.

VT_DECIMAL 14

Indicates a decimal value.

VT_I1 16

Indicates a char value.

VT_UI1 17

Indicates a byte.

VT_UI2 18

Indicates an unsignedshort.

VT_UI4 19

Indicates an unsignedlong.

VT_I8 20

Indicates a 64-bit integer.

VT_UI8 21

Indicates an 64-bit unsigned integer.

VT_INT 22

Indicates an integer value.

VT_UINT 23

Indicates an unsigned integer value.

VT_VOID 24

Indicates a C style void.

VT_HRESULT 25

Indicates an HRESULT.

VT_PTR 26

Indicates a pointer type.

VT_SAFEARRAY 27

Indicates a SAFEARRAY. Not valid in a VARIANT.

VT_CARRAY 28

Indicates a C style array.

VT_USERDEFINED 29

Indicates a user defined type.

VT_LPSTR 30

Indicates a null-terminated string.

VT_LPWSTR 31

Indicates a wide string terminated by null.

VT_RECORD 36

Indicates a user defined type.

VT_FILETIME 64

Indicates a FILETIME value.

VT_BLOB 65

Indicates length prefixed bytes.

VT_STREAM 66

Indicates that the name of a stream follows.

VT_STORAGE 67

Indicates that the name of a storage follows.

VT_STREAMED_OBJECT 68

Indicates that a stream contains an object.

VT_STORED_OBJECT 69

Indicates that a storage contains an object.

VT_BLOB_OBJECT 70

Indicates that a blob contains an object.

VT_CF 71

Indicates the clipboard format.

VT_CLSID 72

Indicates a class ID.

VT_VECTOR 4096

Indicates a simple, counted array.

VT_ARRAY 8192

Indicates a SAFEARRAY pointer.

VT_BYREF 16384

Indicates that a value is a reference.

Examples

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.
//[
//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")]
interface class IMyStorage
{
   [DispId(1)]
   Object^ GetItem( [In,MarshalAs(UnmanagedType::BStr)]String^ bstrName );

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

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

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

   property bool IsEmpty 
   {
      [DispId(4)]
      [returnvalue:MarshalAs(UnmanagedType::VariantBool)]
      bool get();
   }
};
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;
        }
    }
}
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

Remarks

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

Applies to

See also