private static string GetWindowText(IntPtr hWnd) { StringBuilder title = new StringBuilder(Windows.MAXTITLE); int length = Windows._GetWindowText(hWnd, title, title.Capacity + 1); title.Length = length; return(title.ToString()); }