Marshal.GetDelegateForFunctionPointer メソッド

定義

オーバーロード

名前 説明
GetDelegateForFunctionPointer(IntPtr, Type)
古い.

アンマネージ関数ポインターをデリゲートに変換します。

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

アンマネージ関数ポインターを、指定した型のデリゲートに変換します。

GetDelegateForFunctionPointer(IntPtr, Type)

注意事項

GetDelegateForFunctionPointer(IntPtr, Type) may be unavailable in future releases. Instead, use GetDelegateForFunctionPointer<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296521

アンマネージ関数ポインターをデリゲートに変換します。

public:
 static Delegate ^ GetDelegateForFunctionPointer(IntPtr ptr, Type ^ t);
[System.Obsolete("GetDelegateForFunctionPointer(IntPtr, Type) may be unavailable in future releases. Instead, use GetDelegateForFunctionPointer<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296521")]
[System.Security.SecurityCritical]
public static Delegate GetDelegateForFunctionPointer(IntPtr ptr, Type t);
public static Delegate GetDelegateForFunctionPointer(IntPtr ptr, Type t);
[System.Security.SecurityCritical]
public static Delegate GetDelegateForFunctionPointer(IntPtr ptr, Type t);
[<System.Obsolete("GetDelegateForFunctionPointer(IntPtr, Type) may be unavailable in future releases. Instead, use GetDelegateForFunctionPointer<T>(IntPtr). For more info, go to http://go.microsoft.com/fwlink/?LinkID=296521")>]
[<System.Security.SecurityCritical>]
static member GetDelegateForFunctionPointer : nativeint * Type -> Delegate
static member GetDelegateForFunctionPointer : nativeint * Type -> Delegate
[<System.Security.SecurityCritical>]
static member GetDelegateForFunctionPointer : nativeint * Type -> Delegate
Public Shared Function GetDelegateForFunctionPointer (ptr As IntPtr, t As Type) As Delegate

パラメーター

ptr
IntPtr

nativeint

変換するアンマネージ関数ポインター。

t
Type

返されるデリゲートの型。

返品

適切なデリゲート型にキャストできるデリゲート インスタンス。

属性

例外

t パラメーターはデリゲートではないか、ジェネリックです。

ptr パラメーターはnull

-または-

t パラメーターはnull

注釈

GetDelegateForFunctionPointerメソッドとGetFunctionPointerForDelegate メソッドを使用して、デリゲートを双方向にマーシャリングできます。 GetDelegateForFunctionPointerでは、ptrSystem.IntPtrとしてインポートされます。 System.IntPtrは、GetFunctionPointerForDelegateを呼び出してパラメーターとして渡すことによって、マネージド デリゲートに対して取得できます。その後、アンマネージ メソッド内から呼び出すことができます。 パラメーター マーシャラーは、デリゲートへの関数ポインターをマーシャリングすることもできます。

ptr は、既定のプラットフォーム呼び出し規則を使用してアンマネージ メソッド を呼び出すデリゲートに変換されます。 UnmanagedFunctionPointerAttributeをデリゲートに適用することで、呼び出し規則を設定できます。

GetDelegateForFunctionPointer メソッドには、次の制限があります。

  • 相互運用シナリオでは、ジェネリックはサポートされていません。
  • このメソッドは、純粋なアンマネージ関数ポインターにのみ使用できます。
  • このメソッドは、C++ で取得された関数ポインターでは使用できません。

適用対象

GetDelegateForFunctionPointer<TDelegate>(IntPtr)

アンマネージ関数ポインターを、指定した型のデリゲートに変換します。

public:
generic <typename TDelegate>
 static TDelegate GetDelegateForFunctionPointer(IntPtr ptr);
[System.Security.SecurityCritical]
public static TDelegate GetDelegateForFunctionPointer<TDelegate>(IntPtr ptr);
public static TDelegate GetDelegateForFunctionPointer<TDelegate>(IntPtr ptr);
[<System.Security.SecurityCritical>]
static member GetDelegateForFunctionPointer : nativeint -> 'Delegate
static member GetDelegateForFunctionPointer : nativeint -> 'Delegate
Public Shared Function GetDelegateForFunctionPointer(Of TDelegate) (ptr As IntPtr) As TDelegate

型パラメーター

TDelegate

返すデリゲートの型。

パラメーター

ptr
IntPtr

nativeint

変換するアンマネージ関数ポインター。

返品

TDelegate

指定したデリゲート型のインスタンス。

属性

例外

TDelegateジェネリック パラメーターがデリゲートではないか、オープン ジェネリック型です。

ptr パラメーターはnull

注釈

GetDelegateForFunctionPointer<TDelegate>(IntPtr)メソッドとGetFunctionPointerForDelegate<TDelegate>(TDelegate) メソッドを使用して、デリゲートを双方向にマーシャリングできます。

ptr は、既定のプラットフォーム呼び出し規則を使用してアンマネージ メソッド を呼び出すデリゲートに変換されます。 UnmanagedFunctionPointerAttributeをデリゲートに適用することで、呼び出し規則を設定できます。

GetDelegateForFunctionPointer<TDelegate>(IntPtr) メソッドには、次の制限があります。

  • 相互運用シナリオでは、ジェネリックはサポートされていません。
  • このメソッドは、純粋なアンマネージ関数ポインターにのみ使用できます。
  • このメソッドは、C++ で取得された関数ポインターでは使用できません。

適用対象