Marshal.GetIUnknownForObjectInContext(Object) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Devolve uma interface IUnknown de um objeto gerido, se o chamador estiver no mesmo contexto que esse 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
O objeto cuja IUnknown interface é solicitada.
Devoluções
nativeint
O IUnknown ponteiro para o objeto especificado, ou null se o chamador não estiver no mesmo contexto que o objeto especificado.
- Atributos
Exemplos
O exemplo seguinte demonstra como recuperar uma IUnknown interface para um objeto gerido usando o 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
Observações
Este método é o mesmo, GetIUnknownForObject exceto que retorna null se o chamador não estiver no mesmo contexto que o objeto.