我在程序中,想打开三次某个word文档,程序如下。但在打开第二次的时候,HasExited为ture,p.MainWindowHandle有异常发生,请问怎么回事?for(int i=0;i<3;i++)
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE";
p.StartInfo.Arguments = "C:\\Documents and Settings\\wxl\\desktop\\test2.doc";
p.Start();
while(!p.WaitForInputIdle(1000))
{}
IntPtr tmep=p.MainWindowHandle;
}
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE";
p.StartInfo.Arguments = "C:\\Documents and Settings\\wxl\\desktop\\test2.doc";
p.Start();
while(!p.WaitForInputIdle(1000))
{}
IntPtr tmep=p.MainWindowHandle;
}
就算你全面的进程已经退出了,但你到进程列表里面看一下,是不是还有word进程?
打开多个word文档的时候,
为什么打开第二个word文档时,进程会退出?请大家帮帮忙,在此先谢过