Επεξεργασία

Κοινή χρήση μέσω


Marshal.GetComInterfaceForObjectInContext(Object, Type) Method

Definition

Returns an interface pointer that represents the specified interface for an object, if the caller is in the same context as that object.

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

Parameters

o
Object

The object that provides the interface.

t
Type

The type of interface that is requested.

Returns

IntPtr

nativeint

The interface pointer specified by t that represents the interface for the specified object, or null if the caller is not in the same context as the object.

Attributes

Exceptions

t is not an interface.

-or-

The type is not visible to COM.

o does not support the requested interface.

o is null.

-or-

t is null.

Remarks

This method is the same as GetComInterfaceForObject except that it returns null if the caller is not in the same context as the object. It is particularly useful if you have an unmanaged method that expects to be passed an interface pointer.

Applies to

See also