RuntimeMethodHandle.GetFunctionPointer 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得指向此實例所代表方法的指標。
public:
IntPtr GetFunctionPointer();
public IntPtr GetFunctionPointer();
[System.Security.SecurityCritical]
public IntPtr GetFunctionPointer();
member this.GetFunctionPointer : unit -> nativeint
[<System.Security.SecurityCritical>]
member this.GetFunctionPointer : unit -> nativeint
Public Function GetFunctionPointer () As IntPtr
傳回
IntPtr
nativeint
指向此實例所代表的方法指標。
- 屬性
例外狀況
呼叫者沒有執行此操作的必要權限。
備註
若方法有屬性 System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute ,則回傳的值為非管理函式指標,呼叫慣例與屬性中相同。 如果這個 handle 代表的方法是靜態的,那麼回傳的值可以被鑄造成具有相同簽名的 C# 管理函式指標型別。 例如方法手柄,該值不易從使用者程式碼中使用,且僅供執行時使用。
對於沒有 System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute的方法,可以用 Marshal.GetFunctionPointerForDelegate 來取得一個可以傳給原生程式碼的函式指標。