/// <summary> /// 获取子控件句柄 /// </summary> /// <param name="handle"></param> /// <returns></returns> public static List<WindowInfo> EnumChildWindowsCallback(IntPtr handle) { List<WindowInfo> wndList = new List<WindowInfo>(); WinApi.EnumChildWindows(handle, delegate (IntPtr hWnd, int lParam) { WindowInfo wnd = new WindowInfo(); StringBuilder sb = new StringBuilder(256); wnd.hWnd = hWnd; WinApi.GetWindowTextW(hWnd, sb, sb.Capacity); wnd.szWindowName = sb.ToString(); WinApi.GetClassName(hWnd, sb, sb.Capacity); wnd.szClassName = sb.ToString(); wnd.parentHWnd = WinApi.GetParent(hWnd); wnd.id = (int)hWnd; wndList.Add(wnd); return true; }, 0); return wndList; }