下面函数的功能是通过exeFullPath指定的路径,启动进程,获得其窗体标题,然后再结束掉。返回值是窗体标题。现在的问题是,此函数在调试状态下执行能获得ExeTitle的值,而在非调试状态下无法获得。
是不是p.Start()立即执行后p.MainWindowTitle.ToString()还没有值?
请教...
  private string getExeTitleByExeFullPath(string exeFullPath)
        {
            Process p = new Process();
            ProcessStartInfo psInfo = new ProcessStartInfo();
            psInfo.FileName = exeFullPath;
            psInfo.WindowStyle = ProcessWindowStyle.Minimized;
            p.StartInfo = psInfo;
            string ExeTitle = string.Empty;
            if (p.Start())
            { 
                ExeTitle = p.MainWindowTitle.ToString();
            }
            
            //p.Close();
            //p.Kill();
            return ExeTitle;
        }