VarEnum Výčet

Definice

Upozornění

Marshalling VARIANTs may be unavailable in future releases.

Označuje, jak zařadíte prvky pole, když je pole zařazováno ze spravovaného na nespravovaný kód jako 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
Dědičnost
Atributy

Pole

VT_ARRAY 8192

Označuje SAFEARRAY ukazatel.

VT_BLOB 65

Označuje délku předpony bajtů.

VT_BLOB_OBJECT 70

Označuje, že objekt blob obsahuje objekt.

VT_BOOL 11

Označuje logickou hodnotu.

VT_BSTR 8

Označuje řetězec BSTR.

VT_BYREF 16384

Označuje, že hodnota je odkaz.

VT_CARRAY 28

Označuje pole stylu jazyka C.

VT_CF 71

Označuje formát schránky.

VT_CLSID 72

Označuje ID třídy.

VT_CY 6

Označuje hodnotu měny.

VT_DATE 7

Označuje hodnotu DATE.

VT_DECIMAL 14

Označuje decimal hodnotu.

VT_DISPATCH 9

Označuje IDispatch ukazatel.

VT_EMPTY 0

Označuje, že nebyla zadána hodnota.

VT_ERROR 10

Označuje kód SCODE.

VT_FILETIME 64

Označuje hodnotu FILETIME.

VT_HRESULT 25

Označuje HRESULT.

VT_I1 16

Označuje char hodnotu.

VT_I2 2

Označuje short celé číslo.

VT_I4 3

Označuje long celé číslo.

VT_I8 20

Označuje 64bitové celé číslo.

VT_INT 22

Označuje celočíselnou hodnotu.

VT_LPSTR 30

Označuje řetězec ukončený hodnotou null.

VT_LPWSTR 31

Označuje široký řetězec ukončený .null

VT_NULL 1

Označuje hodnotu null, která se podobá hodnotě null v SQL.

VT_PTR 26

Označuje typ ukazatele.

VT_R4 4

Označuje float hodnotu.

VT_R8 5

Označuje double hodnotu.

VT_RECORD 36

Označuje typ definovaný uživatelem.

VT_SAFEARRAY 27

Označuje SAFEARRAY. Ve variantě není platný.

VT_STORAGE 67

Označuje, že název úložiště následuje.

VT_STORED_OBJECT 69

Označuje, že úložiště obsahuje objekt.

VT_STREAM 66

Označuje, že název streamu následuje.

VT_STREAMED_OBJECT 68

Označuje, že datový proud obsahuje objekt.

VT_UI1 17

Označuje byte.

VT_UI2 18

Označuje unsignedshort.

VT_UI4 19

Označuje unsignedlong.

VT_UI8 21

Označuje 64bitové celé číslo bez znaménka.

VT_UINT 23

Označuje celočíselnou unsigned hodnotu.

VT_UNKNOWN 13

Označuje IUnknown ukazatel.

VT_USERDEFINED 29

Označuje typ definovaný uživatelem.

VT_VARIANT 12

Označuje ukazatel VARIANT far .

VT_VECTOR 4096

Označuje jednoduchou počítanou matici.

VT_VOID 24

Označuje styl voidjazyka C .

Příklady

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

Poznámky

System.Runtime.InteropServices.MarshalAsAttribute Slouží k explicitní kontrole typu SafeArrayprvku .

Platí pro

Viz také