Marshal.GetComInterfaceForObject 메서드

정의

개체의 인터페이스를 나타내는 인터페이스 포인터를 반환합니다.

오버로드

GetComInterfaceForObject(Object, Type)
사용되지 않음.

지정된 개체의 지정된 인터페이스를 나타내는 IUnknown 인터페이스에 대한 포인터를 반환합니다. 사용자 지정 쿼리 인터페이스 액세스가 기본적으로 사용됩니다.

GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode)
사용되지 않음.

지정된 개체의 지정된 인터페이스를 나타내는 IUnknown 인터페이스에 대한 포인터를 반환합니다. 사용자 지정 쿼리 인터페이스 액세스는 지정된 사용자 지정 모드에 의해 제어됩니다.

GetComInterfaceForObject<T,TInterface>(T)

지정된 형식의 개체에 지정된 인터페이스를 나타내는 IUnknown 인터페이스에 대한 포인터를 반환합니다. 사용자 지정 쿼리 인터페이스 액세스가 기본적으로 사용됩니다.

GetComInterfaceForObject(Object, Type)

Source:
Marshal.NoCom.cs
Source:
Marshal.NoCom.cs
Source:
Marshal.NoCom.cs

주의

GetComInterfaceForObject(Object, Type) may be unavailable in future releases. Instead, use GetComInterfaceForObject<T,T2>(T). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296509

지정된 개체의 지정된 인터페이스를 나타내는 IUnknown 인터페이스에 대한 포인터를 반환합니다. 사용자 지정 쿼리 인터페이스 액세스가 기본적으로 사용됩니다.

public:
 static IntPtr GetComInterfaceForObject(System::Object ^ o, Type ^ T);
[System.Obsolete("GetComInterfaceForObject(Object, Type) may be unavailable in future releases. Instead, use GetComInterfaceForObject<T,T2>(T). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296509")]
[System.Security.SecurityCritical]
public static IntPtr GetComInterfaceForObject (object o, Type T);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static IntPtr GetComInterfaceForObject (object o, Type T);
[System.Security.SecurityCritical]
public static IntPtr GetComInterfaceForObject (object o, Type T);
public static IntPtr GetComInterfaceForObject (object o, Type T);
[<System.Obsolete("GetComInterfaceForObject(Object, Type) may be unavailable in future releases. Instead, use GetComInterfaceForObject<T,T2>(T). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296509")>]
[<System.Security.SecurityCritical>]
static member GetComInterfaceForObject : obj * Type -> nativeint
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetComInterfaceForObject : obj * Type -> nativeint
[<System.Security.SecurityCritical>]
static member GetComInterfaceForObject : obj * Type -> nativeint
static member GetComInterfaceForObject : obj * Type -> nativeint
Public Shared Function GetComInterfaceForObject (o As Object, T As Type) As IntPtr

매개 변수

o
Object

인터페이스를 제공하는 개체입니다.

T
Type

요청된 인터페이스의 형식입니다.

반환

IntPtr

nativeint

개체에 대해 지정된 인터페이스를 나타내는 인터페이스 포인터입니다.

특성

예외

T 매개 변수가 인터페이스가 아닌 경우

또는

COM에 해당 형식이 표시되지 않는 경우

또는

T 매개 변수는 제네릭 형식 정의입니다.

o 매개 변수가 요청된 인터페이스를 지원하지 않는 경우

o 매개 변수가 null인 경우

또는

T 매개 변수가 null인 경우

설명

이 메서드는 지정된 개체에서 요청된 인터페이스를 나타내는 인터페이스 포인터를 반환합니다. 인터페이스 포인터를 전달해야 하는 관리되지 않는 메서드가 있는 경우 특히 유용합니다. 이 메서드를 사용하여 개체를 호출하면 포인터가 반환되기 전에 인터페이스 포인터에서 참조 수가 증가합니다. 포인터를 완료한 후에는 항상 를 사용하여 Marshal.Release 참조 횟수를 감소합니다. 원시 COM 인터페이스 포인터를 사용할 때 COM에서 정의한 규칙을 준수해야 합니다.

GetComInterfaceForObject(Object, Type) 는 COM 개체 매개 변수를 형식으로 노출하거나 사용자 지정 마샬링을 사용하는 메서드를 IntPtr 호출할 때 유용합니다. 일반적이지는 않지만 관리되는 개체에서 이 메서드를 사용하여 개체의 COM 호출 가능 래퍼에 대한 포인터를 가져올 수 있습니다. 예를 들어 COM으로 내보낸 관리되는 개체에서 를 사용하여 GetComInterfaceForObject(Object, Type) 에 대한 System.Runtime.InteropServices.UCOMIConnectionPointContainer인터페이스 포인터를 가져올 수 있습니다. 클래스 인터페이스에 두 번째 매개 변수(t)에 전달할 해당 형식이 없기 때문에 클래스 인터페이스에 대한 포인터를 가져올 수 없습니다. 대신 를 사용하여 Marshal.GetIDispatchForObject COM 호출 가능 래퍼의 기본 인터페이스(일반적으로 자동 디스패치 클래스 인터페이스)에서 멤버를 호출합니다.

GetComInterfaceForObject(Object, Type) 메서드 오버로드는 기본적으로 쿼리 인터페이스 사용자 지정을 허용합니다. 쿼리 인터페이스 사용자 지정을 적용할지 여부를 지정하려면 메서드 오버로드를 GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode) 사용합니다.

자세한 내용은 COM 호출 가능 래퍼런타임 호출 가능 래퍼 문서를 참조하세요.

추가 정보

적용 대상

GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode)

Source:
Marshal.NoCom.cs
Source:
Marshal.NoCom.cs
Source:
Marshal.NoCom.cs

주의

GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode) and support for ICustomQueryInterface may be unavailable in future releases.

지정된 개체의 지정된 인터페이스를 나타내는 IUnknown 인터페이스에 대한 포인터를 반환합니다. 사용자 지정 쿼리 인터페이스 액세스는 지정된 사용자 지정 모드에 의해 제어됩니다.

public:
 static IntPtr GetComInterfaceForObject(System::Object ^ o, Type ^ T, System::Runtime::InteropServices::CustomQueryInterfaceMode mode);
[System.Obsolete("GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode) and support for ICustomQueryInterface may be unavailable in future releases.")]
[System.Security.SecurityCritical]
public static IntPtr GetComInterfaceForObject (object o, Type T, System.Runtime.InteropServices.CustomQueryInterfaceMode mode);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static IntPtr GetComInterfaceForObject (object o, Type T, System.Runtime.InteropServices.CustomQueryInterfaceMode mode);
[System.Security.SecurityCritical]
public static IntPtr GetComInterfaceForObject (object o, Type T, System.Runtime.InteropServices.CustomQueryInterfaceMode mode);
public static IntPtr GetComInterfaceForObject (object o, Type T, System.Runtime.InteropServices.CustomQueryInterfaceMode mode);
[<System.Obsolete("GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode) and support for ICustomQueryInterface may be unavailable in future releases.")>]
[<System.Security.SecurityCritical>]
static member GetComInterfaceForObject : obj * Type * System.Runtime.InteropServices.CustomQueryInterfaceMode -> nativeint
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetComInterfaceForObject : obj * Type * System.Runtime.InteropServices.CustomQueryInterfaceMode -> nativeint
[<System.Security.SecurityCritical>]
static member GetComInterfaceForObject : obj * Type * System.Runtime.InteropServices.CustomQueryInterfaceMode -> nativeint
static member GetComInterfaceForObject : obj * Type * System.Runtime.InteropServices.CustomQueryInterfaceMode -> nativeint
Public Shared Function GetComInterfaceForObject (o As Object, T As Type, mode As CustomQueryInterfaceMode) As IntPtr

매개 변수

o
Object

인터페이스를 제공하는 개체입니다.

T
Type

요청된 인터페이스의 형식입니다.

mode
CustomQueryInterfaceMode

ICustomQueryInterface에서 제공하는 IUnknown::QueryInterface 사용자 지정을 적용하는지 여부를 나타내는 열거형 값 중 하나입니다.

반환

IntPtr

nativeint

개체에 대한 인터페이스를 나타내는 인터페이스 포인터입니다.

특성

예외

T 매개 변수가 인터페이스가 아닌 경우

또는

COM에 해당 형식이 표시되지 않는 경우

또는

T 매개 변수는 제네릭 형식 정의입니다.

o 개체가 요청된 인터페이스를 지원하지 않는 경우

o 매개 변수가 null인 경우

또는

T 매개 변수가 null인 경우

설명

GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode) 에서는 쿼리 인터페이스 사용자 지정을 적용할지 여부를 지정할 수 있습니다. 오버로드를 GetComInterfaceForObject(Object, Type) 사용하여 기본적으로 쿼리 인터페이스 사용자 지정을 적용합니다.

적용 대상

GetComInterfaceForObject<T,TInterface>(T)

Source:
Marshal.NoCom.cs
Source:
Marshal.NoCom.cs
Source:
Marshal.NoCom.cs

지정된 형식의 개체에 지정된 인터페이스를 나타내는 IUnknown 인터페이스에 대한 포인터를 반환합니다. 사용자 지정 쿼리 인터페이스 액세스가 기본적으로 사용됩니다.

public:
generic <typename T, typename TInterface>
 static IntPtr GetComInterfaceForObject(T o);
[System.Security.SecurityCritical]
public static IntPtr GetComInterfaceForObject<T,TInterface> (T o);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static IntPtr GetComInterfaceForObject<T,TInterface> (T o);
public static IntPtr GetComInterfaceForObject<T,TInterface> (T o);
[<System.Security.SecurityCritical>]
static member GetComInterfaceForObject : 'T -> nativeint
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetComInterfaceForObject : 'T -> nativeint
static member GetComInterfaceForObject : 'T -> nativeint
Public Shared Function GetComInterfaceForObject(Of T, TInterface) (o As T) As IntPtr

형식 매개 변수

T

o의 형식입니다.

TInterface

반환할 인터페이스의 형식입니다.

매개 변수

o
T

인터페이스를 제공하는 개체입니다.

반환

IntPtr

nativeint

TInterface 인터페이스를 나타내는 인터페이스 포인터입니다.

특성

예외

TInterface 매개 변수가 인터페이스가 아닌 경우

또는

COM에 해당 형식이 표시되지 않는 경우

또는

T 매개 변수는 개방형 제네릭 형식입니다.

o 매개 변수가 TInterface 인터페이스를 지원하지 않는 경우

o 매개 변수가 null인 경우

설명

이 메서드는 지정한 개체의 인터페이스를 TInterface 나타내는 인터페이스 포인터를 반환합니다. 인터페이스 포인터를 전달해야 하는 관리되지 않는 메서드가 있는 경우 특히 유용합니다. 이 메서드를 사용하여 개체를 호출하면 포인터가 반환되기 전에 인터페이스 포인터에서 참조 수가 증가합니다. 포인터를 Marshal.Release 완료하면 항상 메서드를 사용하여 참조 횟수를 감소합니다. 원시 COM 인터페이스 포인터를 사용할 때 COM에서 정의한 규칙을 준수해야 합니다.

GetComInterfaceForObject<T,TInterface>(T) 는 COM 개체 매개 변수를 형식으로 노출하거나 사용자 지정 마샬링을 사용하는 메서드를 IntPtr 호출할 때 유용합니다. 관리되는 개체에서 이 메서드를 사용하여 개체의 COM 호출 가능 래퍼에 대한 포인터를 가져올 수도 있습니다. 예를 들어 COM으로 내보낸 관리되는 개체에서 를 사용하여 GetComInterfaceForObject<T,TInterface>(T) 에 대한 System.Runtime.InteropServices.UCOMIConnectionPointContainer인터페이스 포인터를 가져올 수 있습니다.

GetComInterfaceForObject<T,TInterface>(T) 메서드 오버로드는 기본적으로 쿼리 인터페이스 사용자 지정을 허용합니다. 쿼리 인터페이스 사용자 지정을 적용할지 여부를 지정하려면 메서드 오버로드를 GetComInterfaceForObject(Object, Type, CustomQueryInterfaceMode) 사용합니다.

자세한 내용은 COM 호출 가능 래퍼런타임 호출 가능 래퍼 문서를 참조하세요.

적용 대상