VarEnum Enumerazione

Definizione

Attenzione

Marshalling VARIANTs may be unavailable in future releases.

Indica le modalità di esecuzione del marshalling degli elementi della matrice quando viene effettuato il marshalling di una matrice da codice gestito a codice non gestito come 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
Ereditarietà
Attributi

Campi

VT_ARRAY 8192

Indica un puntatore a SAFEARRAY.

VT_BLOB 65

Indica i byte per il prefisso di lunghezza.

VT_BLOB_OBJECT 70

Indica che un blob contiene un oggetto.

VT_BOOL 11

Indica un valore booleano.

VT_BSTR 8

Indica una stringa BSTR.

VT_BYREF 16384

Indica che un valore è un riferimento.

VT_CARRAY 28

Indica una matrice di tipo C.

VT_CF 71

Indica il formato degli Appunti.

VT_CLSID 72

Indica un ID di classe.

VT_CY 6

Indica un valore di valuta.

VT_DATE 7

Indica un valore DATE.

VT_DECIMAL 14

Indica un valore decimal.

VT_DISPATCH 9

Indica un puntatore a IDispatch.

VT_EMPTY 0

Indica che non è stato specificato alcun valore.

VT_ERROR 10

Indica un SCODE.

VT_FILETIME 64

Indica un valore FILETIME.

VT_HRESULT 25

Indica un HRESULT.

VT_I1 16

Indica un valore char.

VT_I2 2

Indica un intero short.

VT_I4 3

Indica un intero long.

VT_I8 20

Indica un valore integer a 64 bit.

VT_INT 22

Indica un intero.

VT_LPSTR 30

Indica una stringa con terminazione di tipo Null.

VT_LPWSTR 31

Indica una stringa di caratteri estesi con terminazione null.

VT_NULL 1

Indica un valore null, simile a un valore null in SQL.

VT_PTR 26

Indica un tipo puntatore.

VT_R4 4

Indica un valore float.

VT_R8 5

Indica un valore double.

VT_RECORD 36

Indica un tipo definito dall'utente.

VT_SAFEARRAY 27

Indica un SAFEARRAY. Non valido in un VARIANT.

VT_STORAGE 67

Indica che segue il nome di un archivio.

VT_STORED_OBJECT 69

Indica che un archivio contiene un oggetto.

VT_STREAM 66

Indica che segue il nome di un flusso.

VT_STREAMED_OBJECT 68

Indica che un flusso contiene un oggetto.

VT_UI1 17

Indica un valore byte.

VT_UI2 18

Indica un valore unsignedshort.

VT_UI4 19

Indica un valore unsignedlong.

VT_UI8 21

Indica un valore integer senza segno a 64 bit.

VT_UINT 23

Indica un intero unsigned.

VT_UNKNOWN 13

Indica un puntatore a IUnknown.

VT_USERDEFINED 29

Indica un tipo definito dall'utente.

VT_VARIANT 12

Indica un puntatore far VARIANT.

VT_VECTOR 4096

Indica una matrice a conteggio semplice.

VT_VOID 24

Indica un void di tipo C.

Esempio

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

Commenti

Usato con System.Runtime.InteropServices.MarshalAsAttribute per controllare in modo esplicito il tipo di elemento dell'oggetto SafeArray.

Si applica a

Vedi anche