Marshal.GetFunctionPointerForDelegate 方法

定義

多載

GetFunctionPointerForDelegate(Delegate)
已淘汰.

將委派轉換成可從 Unmanaged 程式碼呼叫的函式指標。

GetFunctionPointerForDelegate<TDelegate>(TDelegate)

將所指定類型的委派轉換成可從 Unmanaged 程式碼呼叫的函式指標。

GetFunctionPointerForDelegate(Delegate)

來源:
Marshal.cs
來源:
Marshal.cs
來源:
Marshal.cs

警告

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

將委派轉換成可從 Unmanaged 程式碼呼叫的函式指標。

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

參數

d
Delegate

要傳遞至 Unmanaged 程式碼的委派。

傳回

IntPtr

nativeint

可傳遞至 Unmanaged 程式碼的值,然後程式碼就可以用它來呼叫基礎 Managed 委派。

屬性

例外狀況

d 參數是泛型型別定義。

d 參數為 null

備註

委派 d 會轉換成函式指標,可使用 預設平臺呼叫慣例傳遞至 Unmanaged 程式代碼。 您可以將 套用 UnmanagedFunctionPointerAttribute 至委派,以設定呼叫慣例。

您必須手動防止垃圾收集行程從 Managed 程式代碼收集委派。 垃圾收集行程不會追蹤 Unmanaged 程式代碼的參考。

適用於

GetFunctionPointerForDelegate<TDelegate>(TDelegate)

來源:
Marshal.cs
來源:
Marshal.cs
來源:
Marshal.cs

將所指定類型的委派轉換成可從 Unmanaged 程式碼呼叫的函式指標。

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

類型參數

TDelegate

要轉換的委派類型。

參數

d
TDelegate

要傳遞至 Unmanaged 程式碼的委派。

傳回

IntPtr

nativeint

可傳遞至 Unmanaged 程式碼的值,然後程式碼就可以用它來呼叫基礎 Managed 委派。

屬性

例外狀況

d 參數是泛型型別定義。

d 參數為 null

備註

委派 d 會轉換成函式指標,可使用 預設平臺呼叫慣例傳遞至 Unmanaged 程式代碼。 您可以將 套用 UnmanagedFunctionPointerAttribute 至委派,以設定呼叫慣例。

您必須手動防止垃圾收集行程從 Managed 程式代碼收集委派。 垃圾收集行程不會追蹤 Unmanaged 程式代碼的參考。

適用於