Marshal.GetITypeInfoForType(Type) Yöntem

Tanım

Yönetilen türden bir ITypeInfo arabirim döndürür.

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

Parametreler

t
Type

Arabirimi istenen tür ITypeInfo .

Döndürülenler

IntPtr

nativeint

parametresinin ITypeInfo arabirimine yönelik bir t işaretçi.

Öznitelikler

Özel durumlar

t COM için görünür bir tür değildir.

-veya-

tWindows Çalışma Zamanı bir türdür.

Türü içeren derleme için bir tür kitaplığı kaydedilir, ancak tür tanımı bulunamaz.

Örnekler

Aşağıdaki örnek, yöntemini kullanarak bir tür için arabirim işaretçisinin ITypeInfo nasıl alınduğunu GetITypeInfoForType gösterir.

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

Açıklamalar

Bu yöntem, özgün türü temel alan bir uygulamaya yönelik bir ITypeInfo işaretçi döndürür. ile GetITypeInfoForType bir nesnenin çağrılması, başvuru sayısının işaretçi döndürülmeden önce arabirim işaretçisinde artmalarına neden olur. İşaretçiyle işiniz bittiğinde başvuru sayısını azaltmaya yönelik her zaman kullanın Marshal.Release . Standart birlikte çalışma hazırlama davranışını bu özel sıralayıcı ile değiştirmek için uygulamasını uygulayabilirsiniz System.Runtime.InteropServices.MarshalAsAttribute .

Şunlara uygulanır

Ayrıca bkz.