UnmanagedType 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
매개 변수나 필드를 비관리 코드로 마샬링하는 방법을 식별합니다.
public enum class UnmanagedType
public enum UnmanagedType
[System.Serializable]
public enum UnmanagedType
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum UnmanagedType
type UnmanagedType =
[<System.Serializable>]
type UnmanagedType =
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type UnmanagedType =
Public Enum UnmanagedType
- 상속
- 특성
필드
AnsiBStr | 35 | 싱글 바이트 길이 접두사가 있는 ANSI 문자열입니다. String 데이터 형식에 이 멤버를 사용할 수 있습니다. |
AsAny | 40 | 런타임에서 개체의 형식을 결정하고 해당 형식으로 개체를 마샬링하는 동적 형식입니다. 이 메서드는 플랫폼 호출 메서드에만 유효합니다. |
Bool | 2 | 4바이트 부울 값( |
BStr | 19 | 더블바이트 길이 접두사가 있는 유니코드 문자열입니다. COM의 기본 문자열인 이 멤버는 String 데이터 형식에 사용할 수 있습니다. |
ByValArray | 30 | Value 속성이 |
ByValTStr | 23 | 구조체 내에 나타나는 인라인 고정 길이 문자 배열에 사용됩니다. |
Currency | 15 | 통화 형식입니다. |
CustomMarshaler | 44 | MarshalType 또는 MarshalTypeRef 필드와 함께 사용될 때 사용자 지정 마샬러 클래스를 지정합니다. MarshalCookie 필드는 사용자 지정 마샬러에 추가 정보를 전달하는 데 사용할 수 있습니다. 이 멤버는 모든 참조 형식에 사용할 수 있습니다. 이 멤버는 매개 변수 및 반환 값에만 사용할 수 있습니다. 필드에는 사용할 수 없습니다. |
Error | 45 | I4 또는 U4에 연결되어 있으며, 내보낸 형식 라이브러리에서 매개 변수를 HRESULT로 내보내도록 하는 네이티브 형식입니다. |
FunctionPtr | 38 | C 스타일 함수 포인터로 사용할 수 있는 정수입니다. 이 멤버는 Delegate 데이터 형식 또는 Delegate에서 상속된 형식에 사용할 수 있습니다. |
HString | 47 | Windows 런타임 문자열입니다. String 데이터 형식에 이 멤버를 사용할 수 있습니다. |
I1 | 3 | 부호 있는 1바이트 정수입니다. 이 멤버를 사용하여 부울 값을 1바이트 C 스타일 |
I2 | 5 | 부호 있는 2바이트 정수입니다. |
I4 | 7 | 부호 있는 4바이트 정수입니다. |
I8 | 9 | 부호 있는 8바이트 정수입니다. |
IDispatch | 26 | COM |
IInspectable | 46 | Windows 런타임 인터페이스 포인터입니다. Object 데이터 형식에 이 멤버를 사용할 수 있습니다. |
Interface | 28 | COM 인터페이스 포인터. 인터페이스의 Guid는 클래스 메타데이터에서 얻을 수 있습니다. 정확한 인터페이스 형식 또는 클래스에 적용할 경우 기본 인터페이스 형식을 지정하려면 이 멤버를 사용하세요. 이 멤버를 Object 데이터 형식에 적용하면 IUnknown과 같은 동작이 생성됩니다. |
IUnknown | 25 | COM |
LPArray | 42 | C 스타일 배열의 첫 번째 요소에 대한 포인터입니다. 관리되는 코드에서 관리되지 않는 코드로 마샬링하면 배열의 길이는 관리되는 배열의 길이에 의해 결정됩니다. 비관리 코드에서 관리 코드로 마샬링할 때 배열의 길이는 SizeConst 및 SizeParamIndex 필드에서 결정되며, 문자열 형식 간을 구분해야 하는 경우 필요에 따라 배열 내 요소의 관리되지 않는 형식이 뒤에 옵니다. |
LPStr | 20 | 싱글 바이트 null로 끝나는 ANSI 문자열입니다. String 및 StringBuilder 데이터 형식에 이 멤버를 사용할 수 있습니다. |
LPStruct | 43 | 관리되는 서식이 지정된 클래스를 마샬링할 때 사용하는 C 스타일 구조체에 대한 포인터입니다. 이 메서드는 플랫폼 호출 메서드에만 유효합니다. |
LPTStr | 22 | 유니코드 문자열입니다. |
LPUTF8Str | 48 | UTF-8로 인코딩된 문자열에 대한 포인터입니다. |
LPWStr | 21 | 2바이트 null로 끝나는 유니코드 문자열입니다. 관리되지 않는 |
R4 | 11 | 4바이트 부동 소수점 수입니다. |
R8 | 12 | 8바이트 부동 소수점 수입니다. |
SafeArray | 29 | 형식, 차수, 관련된 배열 데이터의 범위를 전달하는 자동 기술 배열인 |
Struct | 27 | 형식이 지정된 관리되는 클래스와 값 형식을 마샬링하는 데 사용되는 VARIANT입니다. |
SysInt | 31 | 플랫폼에 종속적인 부호 있는 정수로, 32비트 Windows의 경우 4바이트이고 64비트 Windows의 경우 8바이트입니다. |
SysUInt | 32 | 플랫폼에 종속적인 부호 없는 정수로, 32비트 Windows의 경우 4바이트이고 64비트 Windows의 경우 8바이트입니다. |
TBStr | 36 | 길이 접두사 유니코드 |
U1 | 4 | 부호 없는 1바이트 정수입니다. |
U2 | 6 | 부호 없는 2바이트 정수입니다. |
U4 | 8 | 부호 없는 4바이트 정수입니다. |
U8 | 10 | 부호 없는 8바이트 정수입니다. |
VariantBool | 37 | 2바이트 OLE 정의 VARIANT_BOOL 형식( |
VBByRefStr | 34 | Visual Basic에서 비관리 코드의 문자열을 변경하고 결과를 관리 코드에 반영되도록 하는 데 사용할 수 있는 값입니다. 이 값은 플랫폼 호출에만 지원됩니다. |
예제
다음 코드 조각에서는 관리되는 소스 코드에서 COM 구성 요소에 의해 구현된 관리되지 않는 인터페이스를 선언하는 방법을 보여 줍니다. 이 특성은 System.Runtime.InteropServices.ComImportAttribute COM에서 IMyStorage
사용하기 위해 인터페이스를 다시 내보내는 것을 방지합니다. (COM 클라이언트는 기존 COM 구성 요소를 직접 사용해야 합니다.) 이 예제 MarshalAsAttribute 에서는 원래 COM 인터페이스에서 사용하는 형식을 나타내는 여러 UnmanagedType 멤버를 지정합니다.
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
설명
특성과 UnmanagedType 함께 System.Runtime.InteropServices.MarshalAsAttribute 열거형을 사용하여 비관리 코드와의 상호 운용 중에 형식이 마샬링되는 방법을 지정합니다. 이 열거형을 사용하여 간단한 값 형식(I1, I2, I4, I8, R4, R8, U2, U4 및 U8), .NET Framework 사용할 수 없는 관리되지 않는 형식 및 다양한 기타 형식을 사용하여 코드를 마샬링할 수 있습니다.
자세한 내용은 비관리 코드 상호 운용을 참조하세요.