文件名称:C#打开exe,doc,excel程序并监视其是否关闭
文件大小:37KB
文件格式:RAR
更新时间:2015-07-20 13:13:57
在C#打开exe,doc,excel程序并监视其是否关闭
PROCESS_INFORMATION pi = new PROCESS_INFORMATION(); STARTUPINFO si = new STARTUPINFO(); si.cb = Marshal.SizeOf(si); StringBuilder sb = new StringBuilder(@"C:\WINDOWS\notepad.exe c:\1.txt"); if (CreateProcess(null,sb, IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, IntPtr.Zero, ref si, ref pi)) { uint result = WaitForSingleObject(pi.hProcess, INFINITE); if (result == WAIT_OBJECT_0) { Int32 returnCode; if (GetExitCodeProcess(pi.hProcess, out returnCode)) { MessageBox.Show("关闭了"); } } CloseHandle(pi.hProcess); CloseHandle(pi.hThread); } 在WinForm中打开Word,Txt等,并监视其关闭
【文件预览】:
WindowsFormsApplication1
----WindowsFormsApplication1()
--------OpenExe.resx(6KB)
--------bin()
--------OpenExe.cs(4KB)
--------obj()
--------Properties()
--------Program.cs(507B)
--------WindowsFormsApplication1.csproj(4KB)
--------OpenExe.Designer.cs(2KB)
----WindowsFormsApplication1.sln(962B)
----WindowsFormsApplication1.suo(19KB)