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 此方法。 如果您有預期要傳遞介面指標的 Unmanaged 方法,它特別有用。

適用於

另請參閱