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
- 상속
- 특성
필드
| Name | 값 | Description |
|---|---|---|
| Bool | 2 | 4 바이트 부울 값( |
| I1 | 3 | 부가된 1 바이트 정수입니다. 이 멤버를 사용하여 부울 값을 1바이트 C 스타일 |
| U1 | 4 | 부호 없는 1 바이트 정수입니다. |
| I2 | 5 | 부가된 2 바이트 정수입니다. |
| U2 | 6 | 부호 없는 2 바이트 정수입니다. |
| I4 | 7 | 부가된 4 바이트 정수입니다. |
| U4 | 8 | 부호 없는 4 바이트 정수입니다. |
| I8 | 9 | 부가된 8 바이트 정수입니다. |
| U8 | 10 | 부호 없는 8 바이트 정수입니다. |
| R4 | 11 | 4 바이트 부동 소수점 숫자입니다. |
| R8 | 12 | 8 바이트 부동 소수점 숫자입니다. |
| Currency | 15 | 통화 유형입니다.
Decimal 10진수 값을 대신 COM 통화 형식 |
| BStr | 19 | 길이 접두사 더블 바이트인 유니코드 문자열입니다. COM의 기본 문자열인 이 멤버를 데이터 형식에서 String 사용할 수 있습니다. |
| LPStr | 20 | null로 끝나는 단일 바이트 ANSI 문자열입니다. 데이터 형식 및 StringBuilder 데이터 형식에서 이 멤버를 String 사용할 수 있습니다. |
| LPWStr | 21 | null로 끝나는 2 바이트 유니코드 문자열입니다. 관리 |
| LPTStr | 22 | 유니코드 문자열입니다. 형식 |
| ByValTStr | 23 | 구조체 내에 나타나는 인라인 고정 길이 문자 배열에 사용됩니다.
|
| IUnknown | 25 | COM |
| IDispatch | 26 | COM |
| Struct | 27 | 관리되는 형식의 클래스 및 값 형식을 마샬링하는 데 사용되는 VARIANT입니다. |
| Interface | 28 | COM 인터페이스 포인터입니다. Guid 인터페이스는 클래스 메타데이터에서 가져옵니다. 클래스에 적용하는 경우 이 멤버를 사용하여 정확한 인터페이스 형식 또는 기본 인터페이스 형식을 지정할 수 있습니다. 이 멤버는 데이터 형식에 적용할 때와 IUnknown 동일한 동작을 Object 생성합니다. |
| SafeArray | 29 | A |
| ByValArray | 30 | 속성이 Value 설정 |
| SysInt | 31 | 플랫폼에 종속된 부호 있는 정수: 32비트 Windows 4바이트, 64비트 Windows 8바이트. |
| SysUInt | 32 | 플랫폼 종속, 부호 없는 정수: 32비트 Windows 4바이트, 64비트 Windows 8바이트. |
| VBByRefStr | 34 | Visual Basic에서 관리되지 않는 코드의 문자열을 변경하고 결과가 관리 코드에 반영되도록 하는 값입니다. 이 값은 플랫폼 호출에 대해서만 지원됩니다. |
| AnsiBStr | 35 | 길이 접두사 싱글 바이트인 ANSI 문자 문자열입니다. 데이터 형식에서 이 멤버를 String 사용할 수 있습니다. |
| TBStr | 36 | 길이 접두사인 유니코드 |
| VariantBool | 37 | 2 바이트 OLE 정의 VARIANT_BOOL 형식( |
| FunctionPtr | 38 | C 스타일 함수 포인터로 사용할 수 있는 정수입니다. 이 멤버는 Delegate 데이터 형식 또는 에서 상속되는 형식에서 Delegate사용할 수 있습니다. |
| AsAny | 40 | 런타임에 개체의 형식을 결정하고 개체를 해당 형식으로 마샬링하는 동적 형식입니다. 이 멤버는 플랫폼 호출 메서드에만 유효합니다. |
| LPArray | 42 | C 스타일 배열의 첫 번째 요소에 대한 포인터입니다. 관리 코드에서 관리되지 않는 코드로 마샬링하는 경우 배열의 길이는 관리되는 배열의 길이에 따라 결정됩니다. 관리되지 않는 코드에서 관리 코드로 마샬링할 때 배열의 길이는 필드와 SizeParamIndex 필드에서 결정 SizeConst 되며, 문자열 형식을 구분해야 할 때 배열 내의 비관리형 요소 형식이 선택적으로 결정됩니다. |
| LPStruct | 43 | 관리되는 형식의 클래스를 마샬링하는 데 사용하는 C 스타일 구조체에 대한 포인터입니다. 이 멤버는 플랫폼 호출 메서드에만 유효합니다. |
| CustomMarshaler | 44 | 또는 MarshalTypeRef 필드와 함께 사용할 때 사용자 지정 마샬러 클래스를 MarshalType 지정합니다. 필드를 MarshalCookie 사용하여 사용자 지정 마샬러에 추가 정보를 전달할 수 있습니다. 모든 참조 형식에서 이 멤버를 사용할 수 있습니다. 이 멤버는 매개 변수 및 반환 값에 대해서만 유효합니다. 필드에는 사용할 수 없습니다. |
| Error | 45 | |
| IInspectable | 46 | Windows 런타임 인터페이스 포인터입니다. 데이터 형식에서 이 멤버를 Object 사용할 수 있습니다. WinRT에 대한 빌드 지원은 .NET 5 제거되었습니다. |
| HString | 47 | Windows 런타임 문자열입니다. 데이터 형식에서 이 멤버를 String 사용할 수 있습니다. WinRT에 대한 빌드 지원은 .NET 5 제거되었습니다. 해결 방법은 이전에 지원되는 기본 제공 형식 을 참조하세요. |
| LPUTF8Str | 48 | UTF-8로 인코딩된 문자열에 대한 포인터입니다. |
예제
다음 코드 조각에서는 관리되는 소스 코드에서 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에서 사용할 수 없는 관리되지 않는 형식 및 다양한 기타 형식을 사용하여 코드를 마샬링할 수 있습니다.
자세한 내용은 비관리 코드 상호 운용을 참조하세요.