Marshal.GetITypeInfoForType メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Marshal.GetITypeInfoForType メソッドの意味・解説 

Marshal.GetITypeInfoForType メソッド

マネージ型から ITypeInfo インターフェイスを返します。

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Function GetITypeInfoForType
 ( _
    t As Type _
) As IntPtr
Dim t As Type
Dim returnValue As IntPtr

returnValue = Marshal.GetITypeInfoForType(t)
public static IntPtr GetITypeInfoForType (
    Type t
)
public:
static IntPtr GetITypeInfoForType (
    Type^ t
)
public static IntPtr GetITypeInfoForType (
    Type t
)
public static function GetITypeInfoForType
 (
    t : Type
) : IntPtr

パラメータ

t

要求されている ITypeInfo インターフェイスを持つ Type。

戻り値
t パラメータの ITypeInfo ポインタ。

例外例外
例外の種類条件

ArgumentException

t が COM から参照できる型ではありません。

COMException

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

解説解説

このメソッドは、元の型をベースにした ITypeInfo の実装へのポインタを返します。GetITypeInfoForType でオブジェクトを呼び出すと、ポインタが返される前に、インターフェイス ポインタで参照カウントがインクリメントされます。ポインタの使用が終わったときは、必ず Marshal.Release を使用して参照カウントをデクリメントしてください。System.Runtime.InteropServices.MarshalAsAttribute を適用すると、相互運用マーシャリングの標準の動作をこのカスタム マーシャラの動作で置き換えることができます。ITypeInfo の詳細については、MSDN ライブラリを参照してください。

メモメモ

このメソッドは SecurityAction.LinkDemand を使用して、信頼関係のないコードからの呼び出しを防ぎます。SecurityPermissionAttribute.UnmanagedCode アクセス許可は、直前の呼び出し元にのみ要求されます。信頼性が一部しか確認されていないコードから呼び出すことができるコードの場合、ユーザー入力を検証せずに Marshal クラスに渡すことは避けてください。LinkDemand メンバの使用に関する重要な制約事項については、「Demand と LinkDemand」を参照してください。

使用例使用例

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

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


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();
    }
}
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Marshal クラス
Marshal メンバ
System.Runtime.InteropServices 名前空間
GetTypeForITypeInfo
MarshalAsAttribute



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

Marshal.GetITypeInfoForType メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Marshal.GetITypeInfoForType メソッドのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS