VarEnum VarEnum VarEnum VarEnum Enum

定义

警告

此 API 现已过时。

指示当数组作为 SafeArray 从托管代码封送到非托管代码时,如何封送该数组的元素。Indicates how to marshal the array elements when an array is marshaled from managed to unmanaged code as a SafeArray.

public enum class VarEnum
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
[System.Obsolete("Marshalling VARIANTs may be unavailable in future releases.")]
public enum VarEnum
type VarEnum = 
Public Enum VarEnum
继承
属性

字段

VT_ARRAY VT_ARRAY VT_ARRAY VT_ARRAY 8192

指示 SAFEARRAY 指针。Indicates a SAFEARRAY pointer.

VT_BLOB VT_BLOB VT_BLOB VT_BLOB 65

指示以长度为前缀的字节。Indicates length prefixed bytes.

VT_BLOB_OBJECT VT_BLOB_OBJECT VT_BLOB_OBJECT VT_BLOB_OBJECT 70

指示 Blob 包含对象。Indicates that a blob contains an object.

VT_BOOL VT_BOOL VT_BOOL VT_BOOL 11

指示一个布尔值。Indicates a Boolean value.

VT_BSTR VT_BSTR VT_BSTR VT_BSTR 8

指示 BSTR 字符串。Indicates a BSTR string.

VT_BYREF VT_BYREF VT_BYREF VT_BYREF 16384

指示值为引用。Indicates that a value is a reference.

VT_CARRAY VT_CARRAY VT_CARRAY VT_CARRAY 28

指示 C 样式数组。Indicates a C style array.

VT_CF VT_CF VT_CF VT_CF 71

指示剪贴板格式。Indicates the clipboard format.

VT_CLSID VT_CLSID VT_CLSID VT_CLSID 72

指示类 ID。Indicates a class ID.

VT_CY VT_CY VT_CY VT_CY 6

指示货币值。Indicates a currency value.

VT_DATE VT_DATE VT_DATE VT_DATE 7

指示 DATE 值。Indicates a DATE value.

VT_DECIMAL VT_DECIMAL VT_DECIMAL VT_DECIMAL 14

指示 decimal 值。Indicates a decimal value.

VT_DISPATCH VT_DISPATCH VT_DISPATCH VT_DISPATCH 9

指示 IDispatch 指针。Indicates an IDispatch pointer.

VT_EMPTY VT_EMPTY VT_EMPTY VT_EMPTY 0

指示未指定值。Indicates that a value was not specified.

VT_ERROR VT_ERROR VT_ERROR VT_ERROR 10

指示 SCODE。Indicates an SCODE.

VT_FILETIME VT_FILETIME VT_FILETIME VT_FILETIME 64

指示 FILETIME 值。Indicates a FILETIME value.

VT_HRESULT VT_HRESULT VT_HRESULT VT_HRESULT 25

指示 HRESULT。Indicates an HRESULT.

VT_I1 VT_I1 VT_I1 VT_I1 16

指示 char 值。Indicates a char value.

VT_I2 VT_I2 VT_I2 VT_I2 2

指示 short 整数。Indicates a short integer.

VT_I4 VT_I4 VT_I4 VT_I4 3

指示 long 整数。Indicates a long integer.

VT_I8 VT_I8 VT_I8 VT_I8 20

指示 64 位整数。Indicates a 64-bit integer.

VT_INT VT_INT VT_INT VT_INT 22

指示整数值。Indicates an integer value.

VT_LPSTR VT_LPSTR VT_LPSTR VT_LPSTR 30

指示一个以 NULL 结尾的字符串。Indicates a null-terminated string.

VT_LPWSTR VT_LPWSTR VT_LPWSTR VT_LPWSTR 31

指示由 null 终止的宽字符串。Indicates a wide string terminated by null.

VT_NULL VT_NULL VT_NULL VT_NULL 1

指示 NULL 值(类似于 SQL 中的 NULL 值)。Indicates a null value, similar to a null value in SQL.

VT_PTR VT_PTR VT_PTR VT_PTR 26

指示指针类型。Indicates a pointer type.

VT_R4 VT_R4 VT_R4 VT_R4 4

指示 float 值。Indicates a float value.

VT_R8 VT_R8 VT_R8 VT_R8 5

指示 double 值。Indicates a double value.

VT_RECORD VT_RECORD VT_RECORD VT_RECORD 36

指示用户定义的类型。Indicates a user defined type.

VT_SAFEARRAY VT_SAFEARRAY VT_SAFEARRAY VT_SAFEARRAY 27

指示 SAFEARRAY。Indicates a SAFEARRAY. 在 VARIANT 中无效。Not valid in a VARIANT.

VT_STORAGE VT_STORAGE VT_STORAGE VT_STORAGE 67

指示随后是存储的名称。Indicates that the name of a storage follows.

VT_STORED_OBJECT VT_STORED_OBJECT VT_STORED_OBJECT VT_STORED_OBJECT 69

指示存储包含对象。Indicates that a storage contains an object.

VT_STREAM VT_STREAM VT_STREAM VT_STREAM 66

指示随后是流的名称。Indicates that the name of a stream follows.

VT_STREAMED_OBJECT VT_STREAMED_OBJECT VT_STREAMED_OBJECT VT_STREAMED_OBJECT 68

指示流包含对象。Indicates that a stream contains an object.

VT_UI1 VT_UI1 VT_UI1 VT_UI1 17

指示 byteIndicates a byte.

VT_UI2 VT_UI2 VT_UI2 VT_UI2 18

指示 unsignedshortIndicates an unsignedshort.

VT_UI4 VT_UI4 VT_UI4 VT_UI4 19

指示 unsignedlongIndicates an unsignedlong.

VT_UI8 VT_UI8 VT_UI8 VT_UI8 21

指示 64 位无符号整数。Indicates an 64-bit unsigned integer.

VT_UINT VT_UINT VT_UINT VT_UINT 23

指示 unsigned 整数值。Indicates an unsigned integer value.

VT_UNKNOWN VT_UNKNOWN VT_UNKNOWN VT_UNKNOWN 13

指示 IUnknown 指针。Indicates an IUnknown pointer.

VT_USERDEFINED VT_USERDEFINED VT_USERDEFINED VT_USERDEFINED 29

指示用户定义的类型。Indicates a user defined type.

VT_VARIANT VT_VARIANT VT_VARIANT VT_VARIANT 12

指示 VARIANTfar 指针。Indicates a VARIANT far pointer.

VT_VECTOR VT_VECTOR VT_VECTOR VT_VECTOR 4096

指示简单的已计数数组。Indicates a simple, counted array.

VT_VOID VT_VOID VT_VOID VT_VOID 24

指示 C 样式 voidIndicates a C style void.

示例

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

注解

用于显式控制的元素类型SafeArraySystem.Runtime.InteropServices.MarshalAsAttributeUsed with System.Runtime.InteropServices.MarshalAsAttribute to explicitly control the element type of the SafeArray.

适用于

另请参阅