VarEnum Énumération

Définition

Attention

Marshalling VARIANTs may be unavailable in future releases.

Indique comment marshaler les éléments de tableau lorsqu’un tableau est marshalé du code managé au code non managé en tant que SafeArray.

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

Champs

Nom Valeur Description
VT_EMPTY 0

Indique qu’une valeur n’a pas été spécifiée.

VT_NULL 1

Indique une valeur Null, similaire à une valeur Null dans SQL.

VT_I2 2

Indique un short entier.

VT_I4 3

Indique un long entier.

VT_R4 4

Indique une float valeur.

VT_R8 5

Indique une double valeur.

VT_CY 6

Indique une valeur monétaire.

VT_DATE 7

Indique une valeur DATE.

VT_BSTR 8

Indique une chaîne BSTR.

VT_DISPATCH 9

Indique un IDispatch pointeur.

VT_ERROR 10

Indique un SCODE.

VT_BOOL 11

Indique une valeur booléenne.

VT_VARIANT 12

Indique un pointeur VARIANT far .

VT_UNKNOWN 13

Indique un IUnknown pointeur.

VT_DECIMAL 14

Indique une decimal valeur.

VT_I1 16

Indique une char valeur.

VT_UI1 17

Indique un byte.

VT_UI2 18

Indique un unsignedshort.

VT_UI4 19

Indique un unsignedlong.

VT_I8 20

Indique un entier 64 bits.

VT_UI8 21

Indique un entier non signé 64 bits.

VT_INT 22

Indique une valeur entière.

VT_UINT 23

Indique une unsigned valeur entière.

VT_VOID 24

Indique un style voidC.

VT_HRESULT 25

Indique un HRESULT.

VT_PTR 26

Indique un type de pointeur.

VT_SAFEARRAY 27

Indique un SAFEARRAY. Non valide dans un VARIANT.

VT_CARRAY 28

Indique un tableau de style C.

VT_USERDEFINED 29

Indique un type défini par l’utilisateur.

VT_LPSTR 30

Indique une chaîne terminée par null.

VT_LPWSTR 31

Indique une chaîne large arrêtée par null.

VT_RECORD 36

Indique un type défini par l’utilisateur.

VT_FILETIME 64

Indique une valeur FILETIME.

VT_BLOB 65

Indique la longueur des octets préfixés.

VT_STREAM 66

Indique que le nom d’un flux suit.

VT_STORAGE 67

Indique que le nom d’un stockage suit.

VT_STREAMED_OBJECT 68

Indique qu’un flux contient un objet.

VT_STORED_OBJECT 69

Indique qu’un stockage contient un objet.

VT_BLOB_OBJECT 70

Indique qu’un objet blob contient un objet.

VT_CF 71

Indique le format du Presse-papiers.

VT_CLSID 72

Indique un ID de classe.

VT_VECTOR 4096

Indique un tableau simple et compté.

VT_ARRAY 8192

Indique un SAFEARRAY pointeur.

VT_BYREF 16384

Indique qu’une valeur est une référence.

Exemples

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

Remarques

Utilisé avec System.Runtime.InteropServices.MarshalAsAttribute pour contrôler explicitement le type d’élément du SafeArray.

S’applique à

Voir aussi