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

注解

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

适用于

另请参阅