Enumeração VarEnum
Dica
The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.
Indica como realizar marshaling dos elementos da matriz quando uma matriz passa por marshaling do código gerenciado para não gerenciado como um UnmanagedType.SafeArray.
Namespace: System.Runtime.InteropServices
Assembly: mscorlib (em mscorlib.dll)
Sintaxe
[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum VarEnum
[SerializableAttribute]
[ComVisibleAttribute(true)]
public enum class VarEnum
[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
type VarEnum
<SerializableAttribute>
<ComVisibleAttribute(True)>
Public Enumeration VarEnum
Membros
Nome do membro | Descrição | |
---|---|---|
VT_ARRAY | Indica um ponteiro SAFEARRAY. |
|
VT_BLOB | Indica os bytes prefixados do comprimento. |
|
VT_BLOB_OBJECT | Indica que um blob contém um objeto. |
|
VT_BOOL | Indica um valor booliano. |
|
VT_BSTR | Indica uma cadeia de caracteres BSTR. |
|
VT_BYREF | Indica que um valor é uma referência. |
|
VT_CARRAY | Indica uma matriz de estilo C. |
|
VT_CF | Indica o formato da área de transferência. |
|
VT_CLSID | Indica uma ID de classe. |
|
VT_CY | Indica um valor de moeda. |
|
VT_DATE | Indica um valor DATE. |
|
VT_DECIMAL | Indica um valor decimal. |
|
VT_DISPATCH | Indica um ponteiro IDispatch. |
|
VT_EMPTY | Indica que não foi especificado um valor. |
|
VT_ERROR | Indica um SCODE. |
|
VT_FILETIME | Indica um valor FILETIME. |
|
VT_HRESULT | Indica um ponteiro HRESULT. |
|
VT_I1 | Indica um valor char. |
|
VT_I2 | Indica um inteiro short. |
|
VT_I4 | Indica um inteiro long. |
|
VT_I8 | Indica um inteiro de 64 bits. |
|
VT_INT | Indica um valor inteiro. |
|
VT_LPSTR | Indica uma cadeia de caracteres terminada em nulo. |
|
VT_LPWSTR | Indica uma cadeia de caracteres larga terminada por null. |
|
VT_NULL | Indica um valor nulo, semelhante a um valor nulo no SQL. |
|
VT_PTR | Indica um tipo de ponteiro. |
|
VT_R4 | Indica um valor float. |
|
VT_R8 | Indica um valor double. |
|
VT_RECORD | Indica um tipo definido pelo usuário. |
|
VT_SAFEARRAY | Indica um SAFEARRAY. Inválido em uma VARIANT. |
|
VT_STORAGE | Indica que o nome de um armazenamento segue. |
|
VT_STORED_OBJECT | Indica que um armazenamento contém um objeto. |
|
VT_STREAM | Indica que o nome de um fluxo segue. |
|
VT_STREAMED_OBJECT | Indica que um fluxo contém um objeto. |
|
VT_UI1 | Indica um byte. |
|
VT_UI2 | Indica um unsignedshort. |
|
VT_UI4 | Indica um unsignedlong. |
|
VT_UI8 | Indica um inteiro sem sinal de 64 bits. |
|
VT_UINT | Indica um valor inteiro unsigned. |
|
VT_UNKNOWN | Indica um ponteiro IUnknown. |
|
VT_USERDEFINED | Indica um tipo definido pelo usuário. |
|
VT_VARIANT | Indica um ponteiro far VARIANT. |
|
VT_VECTOR | Indica uma matriz simples contada. |
|
VT_VOID | Indica um estilo C void. |
Comentários
Usado com System.Runtime.InteropServices.MarshalAsAttribute controlar explicitamente o tipo de elemento de SafeArray.
Exemplos
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();
}
};
Informações de Versão
Plataforma Universal do Windows
Disponível desde 8
.NET Framework
Disponível desde 1.1
Biblioteca de Classes Portátil
Com suporte no: plataformas portáteis do .NET
Windows Phone
Disponível desde 8.1
Confira Também
SafeArray
MarshalAsAttribute
Namespace System.Runtime.InteropServices
Retornar ao início