public static int GetWindowText(IntPtr hWnd, out string text) { WindowsAPI.STRINGBUFFER sTRINGBUFFER = default(WindowsAPI.STRINGBUFFER); int windowText = WindowsAPI.GetWindowText(hWnd, out sTRINGBUFFER, 512); text = sTRINGBUFFER.szText; return(windowText); }