Share via


Marshal.GetComInterfaceForObjectInContext(Object, Type) 方法

定义

返回一个接口指针,该指针表示对象的指定接口(如果调用方与对象在同一上下文中)。

public:
 static IntPtr GetComInterfaceForObjectInContext(System::Object ^ o, Type ^ t);
public static IntPtr GetComInterfaceForObjectInContext (object o, Type t);
[System.Security.SecurityCritical]
public static IntPtr GetComInterfaceForObjectInContext (object o, Type t);
static member GetComInterfaceForObjectInContext : obj * Type -> nativeint
[<System.Security.SecurityCritical>]
static member GetComInterfaceForObjectInContext : obj * Type -> nativeint
Public Shared Function GetComInterfaceForObjectInContext (o As Object, t As Type) As IntPtr

参数

o
Object

提供接口的对象。

t
Type

所请求接口的类型。

返回

IntPtr

nativeint

t 指定的接口指针,用于表示指定对象的接口,或如果调用方与对象不在同一上下文中,则为 null

属性

例外

t 不是接口。

- 或 -

该类型对 COM 不可见。

o 不支持请求的接口。

onull

tnull

注解

此方法与 相同 GetComInterfaceForObject ,只是当调用方与 对象不在同一上下文中时返回 null 。 如果具有需要传递接口指针的非托管方法,则此方法特别有用。

适用于

另请参阅