Your issue might be related to the timing between running your code and calling the Title of the window. You need to check for the main window handle before attempting to retrieve the title after the process has entered the idle state.
I have added a method for you called 'GetMainWindowTitle' to check for the main window handle -
using System;
using System.Diagnostics;
class RunandReadMyProgram
{
static void Main()
{
ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\Windows\System32\calc.exe");
startInfo.UseShellExecute = false;
startInfo.WindowStyle = ProcessWindowStyle.Normal;
var myProcess = Process.Start(startInfo);
myProcess.WaitForInputIdle();
string mainWindowTitle = GetMainWindowTitle(myProcess);
Console.WriteLine("Calculator Window Title: " + mainWindowTitle);
}
static string GetMainWindowTitle(Process process)
{
string title = string.Empty;
if (process.MainWindowHandle != IntPtr.Zero)
{
title = process.MainWindowTitle;
}
return title;
}
}