更新
我有关于Process.Start();
我的程序启动文件的过程中,像这样的一个问题:如何监视启动“dllhost.exe”的进程?
Process processMonitor = new Process();
processMonitor.StartInfo.FileName = filePath; // Example: @"C:\test.txt"
processMonitor.StartInfo.CreateNoWindow = true;
processMonitor.Exited += new EventHandler(Process_Exited);
processMonitor.EnableRaisingEvents = true;
processMonitor.Start();
// Handle Exited event and display process information.
private void Process_Exited(object sender, EventArgs e)
{
// This code is called on every exit, except images: (Windows Photo Viewer, *jpg, *png, *bmp etc.)
}
此成功发射的过程,用的notepad.exe正确的文件。 捕捉已退出的事件也行得通,所以基本上我已经掌握了一切来监视该过程的关闭事件。
现在的问题...
在做完全一样的,但现在的图像:
processMonitor.StartInfo.FileName = filePath; // Example: @"C:\test.jpg"
这不是全成。该过程完全启动,但是我无法检测如果这个过程是封闭的。一个小的研究表明我,这个过程被称为:
DLLHOST.EXE(COM代孕)
启动,我无法检测到已退出事件这一过程。
任何人都可以帮助我,或者至少指向正确的方向吗?
您将需要发布*准确的*代码。您没有订阅Exited事件,因此将CreateNoWindow设置为true是没有意义的。 –
我遇到了一个更奇怪的问题,那就是'调用'Start(“http://www.google.com”)返回的'Process'(打开系统上Google Chrome的默认浏览器)是'null'?我想获得它的'MainWindowHandle',但是因为它是'null',所以我无法做任何事情(启动后)。 –
试试这个:[如何在windows中检测使用c#的进程开始和结束?](http://stackoverflow.com/a/8455896/47733) – lsalamon