VarEnum 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
警告
Marshalling VARIANTs may be unavailable in future releases.
指出當陣列從 Managed 封送處理至 Unmanaged 程式代碼作為 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
- 繼承
- 屬性
欄位
| 名稱 | 值 | Description |
|---|---|---|
| VT_EMPTY | 0 | 表示未指定某個數值。 |
| VT_NULL | 1 | 表示一個空值,類似於 SQL 中的空值。 |
| VT_I2 | 2 | 表示整 |
| VT_I4 | 3 | 表示整 |
| VT_R4 | 4 | 表示一個 |
| VT_R8 | 5 | 表示一個 |
| VT_CY | 6 | 表示貨幣價值。 |
| VT_DATE | 7 | 表示日期值。 |
| VT_BSTR | 8 | 表示 BSTR 字串。 |
| VT_DISPATCH | 9 | 指示指示器 |
| VT_ERROR | 10 | 表示 SCODE。 |
| VT_BOOL | 11 | 表示一個布林值。 |
| VT_VARIANT | 12 | 表示一個變體 |
| VT_UNKNOWN | 13 | 指示指示器 |
| VT_DECIMAL | 14 | 表示一個 |
| VT_I1 | 16 | 表示一個 |
| VT_UI1 | 17 | 表示一個 |
| VT_UI2 | 18 | 表示一個 |
| VT_UI4 | 19 | 表示一個 |
| VT_I8 | 20 | 表示一個 64 位元整數。 |
| VT_UI8 | 21 | 表示一個 64 位元無符號整數。 |
| VT_INT | 22 | 表示整數值。 |
| VT_UINT | 23 | 表示整 |
| VT_VOID | 24 | 表示 C 風格 |
| VT_HRESULT | 25 | 表示有 HRESULTS 的訊號。 |
| VT_PTR | 26 | 表示指標類型。 |
| VT_SAFEARRAY | 27 | 表示 SAFEARRAY。 在變異體中不適用。 |
| VT_CARRAY | 28 | 表示 C 風格陣列。 |
| VT_USERDEFINED | 29 | 表示使用者定義的類型。 |
| VT_LPSTR | 30 | 表示一個終結為空的字串。 |
| VT_LPWSTR | 31 | 表示一條寬字串,末尾為 |
| VT_RECORD | 36 | 表示使用者定義的類型。 |
| VT_FILETIME | 64 | 表示一個 FILETIME 值。 |
| VT_BLOB | 65 | 表示長度為前綴位元組。 |
| VT_STREAM | 66 | 表示後面會有一個溪流的名稱。 |
| VT_STORAGE | 67 | 表示後面會跟著儲存的名稱。 |
| VT_STREAMED_OBJECT | 68 | 表示串流包含一個物件。 |
| VT_STORED_OBJECT | 69 | 表示儲存包含物件。 |
| VT_BLOB_OBJECT | 70 | 表示一個 blob 包含一個物件。 |
| VT_CF | 71 | 表示剪貼板格式。 |
| VT_CLSID | 72 | 顯示有班級識別碼。 |
| VT_VECTOR | 4096 | 表示一個簡單的計數陣列。 |
| VT_ARRAY | 8192 | 指示指示器 |
| VT_BYREF | 16384 | 表示某值是參考值。 |
範例
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
備註
用來 System.Runtime.InteropServices.MarshalAsAttribute 明確控制元素類型的 SafeArray類型。