Marshal.GetIUnknownForObjectInContext(Object) Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Devuelve una interfaz IUnknown de un objeto administrado, si el autor de la llamada está en el mismo contexto que ese objeto.
public:
static IntPtr GetIUnknownForObjectInContext(System::Object ^ o);
public static IntPtr GetIUnknownForObjectInContext(object o);
[System.Security.SecurityCritical]
public static IntPtr GetIUnknownForObjectInContext(object o);
static member GetIUnknownForObjectInContext : obj -> nativeint
[<System.Security.SecurityCritical>]
static member GetIUnknownForObjectInContext : obj -> nativeint
Public Shared Function GetIUnknownForObjectInContext (o As Object) As IntPtr
Parámetros
- o
- Object
Objeto cuya IUnknown interfaz se solicita.
Devoluciones
nativeint
Puntero IUnknown para el objeto especificado o null si el autor de la llamada no está en el mismo contexto que el objeto especificado.
- Atributos
Ejemplos
En el ejemplo siguiente se muestra cómo recuperar una IUnknown interfaz para un objeto administrado mediante el GetIUnknownForObjectInContext método .
using System;
using System.Runtime.InteropServices;
class Program
{
static void Run()
{
// Create an int object
int obj = 1;
Console.WriteLine("Calling Marshal.GetIUnknownForObjectInContext...");
// Get the IUnKnown pointer for the Integer object
IntPtr pointer = Marshal.GetIUnknownForObjectInContext(obj);
Console.WriteLine("Calling Marshal.Release...");
// Always call Marshal.Release to decrement the reference count.
Marshal.Release(pointer);
}
static void Main(string[] args)
{
Run();
}
}
Imports System.Runtime.InteropServices
Module Program
Sub Run()
' Dim an Integer object
Dim IntegerObject As Integer = 1
' Dim a pointer
Dim pointer As IntPtr
Console.WriteLine("Calling Marshal.GetIUnknownForObjectInContext...")
' Get the IUnKnown pointer for the Integer object
pointer = Marshal.GetIUnknownForObjectInContext(IntegerObject)
Console.WriteLine("Calling Marshal.Release...")
' Always call Marshal.Release to decrement the reference count.
Marshal.Release(pointer)
End Sub
Sub Main(ByVal args() As String)
Run()
End Sub
End Module
Comentarios
Este método es el mismo que GetIUnknownForObject , salvo que devuelve null si el autor de la llamada no está en el mismo contexto que el objeto .