Export (0) Print
Expand All
Expand Minimize

Marshal.GetFunctionPointerForDelegate Method

Converts a delegate into a function pointer callable from unmanaged code.

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)

public static IntPtr GetFunctionPointerForDelegate (
	Delegate d
)
public static IntPtr GetFunctionPointerForDelegate (
	Delegate d
)
public static function GetFunctionPointerForDelegate (
	d : Delegate
) : IntPtr
Not applicable.

Parameters

d

The delegate to be passed to unmanaged code.

Return Value

An System.IntPtr value that can be passed to unmanaged code, which in turn can use it to call the underlying managed delegate.

Exception typeCondition

ArgumentException

The d parameter is a generic type

ArgumentNullException

The d parameter is a null reference (Nothing in Visual Basic).

The delegate d is converted to a function pointer that can be passed to unmanaged code using the __stdcall calling convention.

Note that you must manually keep the delegate from being collected by the garbage collector (GC) from managed code. The GC does not track reference to unmanaged code.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft