VarEnum Enumeration

Definition

Achtung

Marshalling VARIANTs may be unavailable in future releases.

Gibt an, wie die Arrayelemente gemarshallt werden sollen, wenn ein Array als SafeArray aus verwaltetem in nicht verwalteten Code gemarshallt wird.

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
Vererbung
Attribute

Felder

VT_ARRAY 8192

Gibt einen SAFEARRAY-Zeiger an.

VT_BLOB 65

Gibt Bytes mit Längenpräfix an.

VT_BLOB_OBJECT 70

Gibt an, dass ein BLOB ein Objekt enthält.

VT_BOOL 11

Gibt einen booleschen Wert an.

VT_BSTR 8

Gibt eine BSTR-Zeichenfolge an.

VT_BYREF 16384

Gibt an, dass ein Wert ein Verweis ist.

VT_CARRAY 28

Gibt ein C-Array an.

VT_CF 71

Gibt das Format der Zwischenablage an.

VT_CLSID 72

Gibt eine Klassen-ID an.

VT_CY 6

Gibt einen Währungswert an.

VT_DATE 7

Gibt einen DATE-Wert an.

VT_DECIMAL 14

Gibt einen decimal-Wert an.

VT_DISPATCH 9

Gibt einen IDispatch-Zeiger an.

VT_EMPTY 0

Gibt an, dass kein Wert angegeben wurde.

VT_ERROR 10

Gibt einen SCODE an.

VT_FILETIME 64

Gibt einen FILETIME-Wert an.

VT_HRESULT 25

Gibt ein HRESULT an.

VT_I1 16

Gibt einen char-Wert an.

VT_I2 2

Gibt eine short-Ganzzahl an.

VT_I4 3

Gibt eine long-Ganzzahl an.

VT_I8 20

Gibt einen 64-Bit-Integer-Wert an.

VT_INT 22

Gibt einen Ganzzahlwert an.

VT_LPSTR 30

Gibt eine auf NULL endende Zeichenfolge an.

VT_LPWSTR 31

Gibt eine auf null endende breite Zeichenfolge an.

VT_NULL 1

Gibt einen NULL-Wert an, der mit einem NULL-Wert in SQL vergleichbar ist.

VT_PTR 26

Gibt einen Zeigertyp an.

VT_R4 4

Gibt einen float-Wert an.

VT_R8 5

Gibt einen double-Wert an.

VT_RECORD 36

Gibt einen benutzerdefinierten Typ an.

VT_SAFEARRAY 27

Gibt ein SAFEARRAY an. In einem VARIANT nicht gültig.

VT_STORAGE 67

Gibt an, dass der Name eines Speichers folgt.

VT_STORED_OBJECT 69

Gibt an, dass ein Speicher ein Objekt enthält.

VT_STREAM 66

Gibt an, dass der Name eines Streams folgt.

VT_STREAMED_OBJECT 68

Gibt an, dass ein Stream ein Objekt enthält.

VT_UI1 17

Gibt ein byte an.

VT_UI2 18

Gibt ein unsignedshort an.

VT_UI4 19

Gibt ein unsignedlong an.

VT_UI8 21

Gibt einen 64-Bit-Unsigned Integer-Wert an.

VT_UINT 23

Gibt einen unsigned-Ganzzahlwert an.

VT_UNKNOWN 13

Gibt einen IUnknown-Zeiger an.

VT_USERDEFINED 29

Gibt einen benutzerdefinierten Typ an.

VT_VARIANT 12

Gibt einen VARIANT-far-Zeiger an.

VT_VECTOR 4096

Gibt ein einfaches, gezähltes Array an.

VT_VOID 24

Gibt void im Stil von C an.

Beispiele

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

Hinweise

Wird verwendet, System.Runtime.InteropServices.MarshalAsAttribute um den Elementtyp des SafeArrayElements explizit zu steuern.

Gilt für

Siehe auch