更新:2007 年 11 月
下表显示了如何将托管委托封送到非托管代码中的函数指针的示例。
public delegate int EnumDelegate(
IntPtr hwnd, int LParam);
[DllImport("coredll.dll")]
static extern int EnumWindows(
EnumDelegate d,
Int lParm);
|
typedef BOOL (* WNDENUMPROC)
(HWND, LPARAM);
BOOL EnumWindows(
WNDENUMPROC lpEnumFunc,
LPARAM lParam);
|
public delegate int EnumDelegate(
IntPtr hwnd, int lParam);
[DllImport("coredll.dll")]
static extern int EnumWindows(
[MarshalAs(UnmanagedType.FunctionPtr0]
EnumDelegate d,
Int lParam);
|
typedef BOOL (* WNDENUMPROC)
(HWND, LPARAM);
BOOL EnumWindows(
WNDENUMPROC lpENumFunc,
LPARAM lParam);
|
请参见
其他资源
.NET Compact Framework 中的封送处理支持