Marshal.GetIUnknownForObjectInContext(Object) 메서드

정의

호출자가 관리되는 개체와 같은 컨텍스트에 있는 경우 해당 개체에서 IUnknown 인터페이스를 반환합니다.

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

매개 변수

o
Object

IUnknown 인터페이스가 요청되는 개체입니다.

반환

IntPtr

nativeint

지정된 개체에 대한 IUnknown 포인터이거나 호출자가 지정된 개체와 같은 컨텍스트에 없는 경우 null입니다.

특성

예제

다음 예제에서는 메서드를 사용 하 여 관리되는 개체에 대 한 인터페이스를 검색 IUnknown 하는 GetIUnknownForObjectInContext 방법을 보여 줍니다.

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

설명

이 메서드는 호출자가 개체와 GetIUnknownForObject 동일한 컨텍스트에 있지 않은 경우 반환 null 한다는 점을 제외하고 동일합니다.

적용 대상

추가 정보