private void AttachOutputRedirection(PROCESS_INFORMATION processInformation) { Process process = Process.GetProcessById((int)processInformation.dwProcessId); process.OutputDataReceived += new DataReceivedEventHandler(OutputDataReceived); process.ErrorDataReceived += new DataReceivedEventHandler(ErrorDataReceived); process.BeginOutputReadLine(); process.BeginErrorReadLine(); }
static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation);
public static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, ProcessCreationFlags dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo, out PROCESS_INFORMATION lpProcessInformation);