请问C# EnumChildWindows枚举子窗口句柄怎么用法,点击按钮怎么获取全部子句柄数据?我不懂回调函数,请各位指教一下,谢谢!
下面是枚举子句柄的win32 API
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);//查找窗口句柄
[DllImport("User32.dll ")]
public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr childe, string strclass, string FrmText);//查找窗口中子窗口的句柄
[DllImport("user32.dll")]
public static extern int EnumChildWindows(IntPtr hWndParent, CallBack lpEnumFunc, int lParam);//枚举子窗口句柄
public delegate bool CallBack(IntPtr hwnd, int lParam);//回调函数声明,后续还要实现回调函数实体。
private void button1_Click(object sender, EventArgs e)
{
IntPtr hwnd = FindWindow(null, "qq");
IntPtr htextbox = FindWindowEx(hwnd, IntPtr.Zero, "小明", null);
//Console.WriteLine(htextbox);
int ecw=EnumChildWindows(12345,,);//比如父句柄是12345,如何枚举输出全部子句柄
//Console.WriteLine(ecw);
}