It's not quite that simple: a process can have a number of threads, which can have a number of windows each...
But, this should get you started:
[DllImport("user32", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private extern static bool EnumThreadWindows(int threadId, EnumWindowsProc callback, IntPtr lParam);
[DllImport("user32", SetLastError = true, CharSet = CharSet.Auto)]
private extern static int GetWindowText(IntPtr hWnd, StringBuilder text, int maxCount);
private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
public IEnumerable<string> GetWindowText(Process p)
{
List<string> titles = new List<string>();
foreach (ProcessThread t in p.Threads)
{
EnumThreadWindows(t.Id, (hWnd, lParam) =>
{
StringBuilder text = new StringBuilder(200);
GetWindowText(hWnd, text, 200);
titles.Add(text.ToString());
return true;
}, IntPtr.Zero);
}
return titles;
}