VarEnum Enumeração
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Cuidado
Marshalling VARIANTs may be unavailable in future releases.
Indica como fazer marshaling dos elementos da matriz quando uma matriz é marshalada de código gerenciado para não gerenciado como um 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
- Herança
- Atributos
Campos
| Nome | Valor | Description |
|---|---|---|
| VT_EMPTY | 0 | Indica que um valor não foi especificado. |
| VT_NULL | 1 | Indica um valor nulo, semelhante a um valor nulo no SQL. |
| VT_I2 | 2 | Indica um |
| VT_I4 | 3 | Indica um |
| VT_R4 | 4 | Indica um |
| VT_R8 | 5 | Indica um |
| VT_CY | 6 | Indica um valor de moeda. |
| VT_DATE | 7 | Indica um valor DATE. |
| VT_BSTR | 8 | Indica uma cadeia de caracteres BSTR. |
| VT_DISPATCH | 9 | Indica um |
| VT_ERROR | 10 | Indica um SCODE. |
| VT_BOOL | 11 | Indica um valor booliano. |
| VT_VARIANT | 12 | Indica um ponteiro VARIANT |
| VT_UNKNOWN | 13 | Indica um |
| VT_DECIMAL | 14 | Indica um |
| VT_I1 | 16 | Indica um |
| VT_UI1 | 17 | Indica um |
| VT_UI2 | 18 | Indica um |
| VT_UI4 | 19 | Indica um |
| VT_I8 | 20 | Indica um inteiro de 64 bits. |
| VT_UI8 | 21 | Indica um inteiro sem sinal de 64 bits. |
| VT_INT | 22 | Indica um valor inteiro. |
| VT_UINT | 23 | Indica um |
| VT_VOID | 24 | Indica um estilo |
| VT_HRESULT | 25 | Indica um HRESULT. |
| VT_PTR | 26 | Indica um tipo de ponteiro. |
| VT_SAFEARRAY | 27 | Indica um SAFEARRAY. Não é válido em um VARIANT. |
| VT_CARRAY | 28 | Indica uma matriz de estilo C. |
| VT_USERDEFINED | 29 | Indica um tipo definido pelo usuário. |
| VT_LPSTR | 30 | Indica uma cadeia de caracteres terminada em nulo. |
| VT_LPWSTR | 31 | Indica uma cadeia de caracteres larga terminada por |
| VT_RECORD | 36 | Indica um tipo definido pelo usuário. |
| VT_FILETIME | 64 | Indica um valor FILETIME. |
| VT_BLOB | 65 | Indica o comprimento prefixado bytes. |
| VT_STREAM | 66 | Indica que o nome de um fluxo segue. |
| VT_STORAGE | 67 | Indica que o nome de um armazenamento segue. |
| VT_STREAMED_OBJECT | 68 | Indica que um fluxo contém um objeto. |
| VT_STORED_OBJECT | 69 | Indica que um armazenamento contém um objeto. |
| VT_BLOB_OBJECT | 70 | Indica que um blob contém um objeto. |
| VT_CF | 71 | Indica o formato da área de transferência. |
| VT_CLSID | 72 | Indica uma ID de classe. |
| VT_VECTOR | 4096 | Indica uma matriz simples e contada. |
| VT_ARRAY | 8192 | Indica um |
| VT_BYREF | 16384 | Indica que um valor é uma referência. |
Exemplos
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
Comentários
Usado para System.Runtime.InteropServices.MarshalAsAttribute controlar explicitamente o tipo de elemento do SafeArray.