【问题标题】:create process and attach C#创建进程并附加 C#
【发布时间】:2013-05-03 19:16:44
【问题描述】:

我有一个疑问,当我创建一个新进程iexplore,并且这个进程打开一个页面时,我想知道页面是否正确加载。我如何知道页面加载是否失败?有什么方法可以从iexplore 进程中捕获错误?

我有这个演示代码,但不能正常工作

string navegador = "C:\\program files (x86)\\Internet Explorer\\iexplore.exe";
Process p = new Process();
p.StartInfo.FileName = navegador;
ProcessStartInfo processStartInfo = new ProcessStartInfo(navegador);
p.EnableRaisingEvents = false;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo = processStartInfo;
p.StartInfo.Arguments = "google.com";

p.Start();

Process currentProcess = Process.GetCurrentProcess();
Process[] localByName = Process.GetProcessesByName("iexplore");
Process[] localAll = Process.GetProcesses();


p.OutputDataReceived += new DataReceivedEventHandler(
                        prsProjectTypes_OutputDataReceived);
p.BeginOutputReadLine();

errorMessage = p.StandardError.ReadToEnd();
p.WaitForExit();

感谢您的帮助。

【问题讨论】:

  • 很明显英语不是你的母语,这很好,但你的问题几乎无法理解。
  • 尝试改写问题,请看看它是否更好并且仍然反映您的任务。您能说出您要监控的确切错误情况是什么吗?

标签: c# .net winforms process


【解决方案1】:

假设您正在使用 WPF,您应该查看 Web 浏览器控件,而不是启动单独的进程。这将使您能够访问 LoadCompleted 事件,这似乎是您正在寻找的。​​p>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-22
    • 2016-12-08
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    相关资源
    最近更新 更多