private string StringFormat(ref string tab) { string rslt = ""; if (hWnd != IntPtr.Zero) { int length = WinAPI.GetWindowTextLength(hWnd); StringBuilder windowName = new StringBuilder(length + 1); WinAPI.GetWindowText(hWnd, windowName, windowName.Capacity); string winClass = WinAPI.GetWinClass(hWnd); uint pid = 0; WinAPI.GetWindowThreadProcessId(hWnd, out pid); rslt += string.Format("HWND:{0}, WinText:{1}, ClassType:{2}, ProcessID:{3}", hWnd.ToString("X8"), windowName.ToString(), winClass, pid.ToString("X8")) + "\n"; } tab += " "; foreach (WinTree tree in subWin) { rslt += tab + tree.StringFormat(ref tab); } tab = tab.Substring(0, tab.Length - 4); return(rslt); }
private static bool CheckByName(IntPtr hWnd, String name, ref int rowId) { string winClass = WinAPI.GetWinClass(hWnd); if (winClass != "SysListView32") { return(false); } //Console.WriteLine(string.Format("{0} {1}", hWnd.ToString("x8"), winClass)); int rowNum = WinAPI.GetListViewItemNum(hWnd); for (int i = 0; i < rowNum; i++) { string strText = WinAPI.GetListViewItemText(hWnd, i); if (strText.Contains(name)) { rowId = i; return(true); } } return(false); }