上传者: cyj380236628
|
上传时间: 2022-03-21 14:39:25
|
文件大小: 37KB
|
文件类型: -
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等,并监视其关闭