public static string GetWindowTitle(IntPtr hWnd) { if (!WindowFunctions.IsWindowVisible(hWnd)) { return(""); } int length = WindowFunctions.GetWindowTextLength(hWnd); if (length == 0) { return(""); } StringBuilder builder = new StringBuilder(length); WindowFunctions.GetWindowText(hWnd, builder, length + 1); return(builder.ToString()); }