Freigeben über


VarEnum-Enumeration

 

Veröffentlicht: Oktober 2016

Gibt an, wie die Arrayelemente gemarshallt werden, wenn ein Array aus verwaltetem in nicht verwaltetem Code als gemarshallt ist eine UnmanagedType.SafeArray.

Namespace:   System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

Syntax

[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum VarEnum
[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum class VarEnum
[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
type VarEnum
<SerializableAttribute>
<ComVisibleAttribute(True)>
Public Enumeration VarEnum

Member

Membername Beschreibung
VT_ARRAY

Gibt einen SAFEARRAY Zeiger.

VT_BLOB

Gibt die Bytes mit Längenpräfix an.

VT_BLOB_OBJECT

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

VT_BOOL

Gibt einen booleschen Wert an.

VT_BSTR

Gibt eine BSTR-Zeichenfolge an.

VT_BYREF

Gibt an, dass ein Wert ein Verweis ist.

VT_CARRAY

Gibt ein Array der C-Format an.

VT_CF

Gibt das Format der Zwischenablage an.

VT_CLSID

Gibt eine Klassen-ID

VT_CY

Gibt einen Währungswert an.

VT_DATE

Gibt einen DATE-Wert an.

VT_DECIMAL

Gibt einen decimal Wert.

VT_DISPATCH

Gibt eine IDispatch Zeiger.

VT_EMPTY

Gibt an, dass kein Wert angegeben wurde.

VT_ERROR

Gibt einen SCODE an.

VT_FILETIME

Gibt einen FILETIME-Wert.

VT_HRESULT

Gibt ein HRESULT an.

VT_I1

Gibt einen char Wert.

VT_I2

Gibt eine short ganze Zahl.

VT_I4

Gibt eine long ganze Zahl.

VT_I8

Gibt eine 64-Bit-Ganzzahl.

VT_INT

Gibt einen ganzzahligen Wert an.

VT_LPSTR

Gibt eine Null-terminierte Zeichenfolge an.

VT_LPWSTR

Gibt eine Breite Zeichenfolge beendet null.

VT_NULL

Gibt einen null-Wert, einen null-Wert in SQL ähnelt.

VT_PTR

Gibt einen Zeiger.

VT_R4

Gibt einen float Wert.

VT_R8

Gibt einen double Wert.

VT_RECORD

Gibt einen benutzerdefinierten Typ an.

VT_SAFEARRAY

Gibt ein SAFEARRAY an. In einer Variante ist ungültig.

VT_STORAGE

Gibt an, dass der Name eines Speichers folgt.

VT_STORED_OBJECT

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

VT_STREAM

Gibt an, dass der Name eines Streams folgt.

VT_STREAMED_OBJECT

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

VT_UI1

Gibt eine byte.

VT_UI2

Gibt eine unsignedshort.

VT_UI4

Gibt eine unsignedlong.

VT_UI8

Gibt eine 64-Bit-Ganzzahl ohne Vorzeichen.

VT_UINT

Gibt eine unsigned Integer-Wert.

VT_UNKNOWN

Gibt eine IUnknown Zeiger.

VT_USERDEFINED

Gibt einen benutzerdefinierten Typ an.

VT_VARIANT

Gibt eine Variante far Zeiger.

VT_VECTOR

Gibt ein einfaches, gezähltes Array an.

VT_VOID

Gibt einen C-Stil void.

Hinweise

Mit verwendet System.Runtime.InteropServices.MarshalAsAttribute den Elementtyp des explizit steuern die SafeArray.

Beispiele

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

Versionsinformationen

Universelle Windows-Plattform
Verfügbar seit 8
.NET Framework
Verfügbar seit 1.1
Portierbare Klassenbibliothek
Unterstützt in: portierbare .NET-Plattformen
Windows Phone
Verfügbar seit 8.1

Siehe auch

SafeArray
MarshalAsAttribute
System.Runtime.InteropServices-Namespace

Zurück zum Anfang