首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么调用DLL中参数带函数指针的函数

2011-12-22 
如何调用DLL中参数带函数指针的函数?请较![解决办法]using Systemusing System.Runtime.InteropServices

如何调用DLL中参数带函数指针的函数?
请较!

[解决办法]
using System;
using System.Runtime.InteropServices;

public delegate bool CallBack(int hwnd, int lParam);

public class EnumReportApp {

[DllImport( "user32 ")]
public static extern int EnumWindows(CallBack x, int y);

public static void Main()
{
CallBack myCallBack = new CallBack(EnumReportApp.Report);
EnumWindows(myCallBack, 0);
}

public static bool Report(int hwnd, int lParam) {
Console.Write( "Window handle is ");
Console.WriteLine(hwnd);
return true;
}
}

热点排行