Marshal.GetITypeInfoForType(Type) 메서드

정의

관리되는 형식에서 ITypeInfo 인터페이스를 반환합니다.

public:
 static IntPtr GetITypeInfoForType(Type ^ t);
public static IntPtr GetITypeInfoForType (Type t);
[System.Security.SecurityCritical]
public static IntPtr GetITypeInfoForType (Type t);
static member GetITypeInfoForType : Type -> nativeint
[<System.Security.SecurityCritical>]
static member GetITypeInfoForType : Type -> nativeint
Public Shared Function GetITypeInfoForType (t As Type) As IntPtr

매개 변수

t
Type

ITypeInfo 인터페이스가 요청 중인 형식입니다.

반환

IntPtr

nativeint

t 매개 변수의 ITypeInfo 인터페이스에 대한 포인터입니다.

특성

예외

t가 COM의 표시 형식이 아닌 경우

또는

t는 Windows 런타임 형식입니다.

형식 라이브러리가 해당 형식을 포함하는 어셈블리에 대해 등록되어 있지만 형식 정의를 찾을 수 없습니다.

예제

다음 예제에서는 메서드를 사용 하 여 GetITypeInfoForType 형식에 대 한 인터페이스에 ITypeInfo 대 한 포인터를 검색 하는 방법을 보여 줍니다.

using System;
using System.Runtime.InteropServices;

class Program
{

    static void Run()
    {
        Console.WriteLine("Calling Marshal.GetITypeInfoForType...");

        // Get the ITypeInfo pointer for an Object type
        IntPtr pointer = Marshal.GetITypeInfoForType(typeof(object));

        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 a pointer
        Dim pointer As IntPtr

        Console.WriteLine("Calling Marshal.GetIUnknownForObjectInContext...")

        ' Get the ITypeInfo pointer for an Object type
        pointer = Marshal.GetITypeInfoForType(Type.GetType("System.Object"))

        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

설명

이 메서드는 원래 형식을 기반으로 하는 구현에 ITypeInfo 대한 포인터를 반환합니다. 를 사용하여 GetITypeInfoForType 개체를 호출하면 포인터가 반환되기 전에 인터페이스 포인터에서 참조 수가 증가합니다. 포인터를 완료한 후에는 항상 를 사용하여 Marshal.Release 참조 수를 감소합니다. 를 적용 System.Runtime.InteropServices.MarshalAsAttribute 하여 표준 interop 마샬링 동작을 이 사용자 지정 마샬러로 바꿀 수 있습니다.

적용 대상

추가 정보