Marshal.GetComInterfaceForObjectInContext(Object, Type) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
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
o
does not support the requested interface.
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.