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 ランタイム型です。

型を格納するアセンブリのタイプ ライブラリが登録されていますが、型定義が見つかりません。

次の例では、メソッドを使用して型の ITypeInfo インターフェイスへのポインターを取得する方法を GetITypeInfoForType 示します。

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 相互運用マーシャリング動作を、このカスタム マーシャラーに置き換える場合に適用できます。

適用対象

こちらもご覧ください