调用控制台程序函数 RunProcess
2006-08-30 16:45
232 查看
函数定义
private void RunProcess(String executable, String args,Boolean output)
{
#region
String line = String.Empty;
proc=new Process();
try
{
proc.StartInfo.FileName = executable;
proc.StartInfo.Arguments = args;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = output;
proc.StartInfo.RedirectStandardError = output;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
}
catch(Exception ex)
{
ex.ToString();
}
finally
{
proc = null;
}
#endregion
}
说明:
executable:控制台程序的exe文件所在路径和xxx.exe
args:运行参数
output:true
private void RunProcess(String executable, String args,Boolean output)
{
#region
String line = String.Empty;
proc=new Process();
try
{
proc.StartInfo.FileName = executable;
proc.StartInfo.Arguments = args;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = output;
proc.StartInfo.RedirectStandardError = output;
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
}
catch(Exception ex)
{
ex.ToString();
}
finally
{
proc = null;
}
#endregion
}
说明:
executable:控制台程序的exe文件所在路径和xxx.exe
args:运行参数
output:true
相关文章推荐
- GUI程序如何使用控制台输出调试信息[zz][MFC调用win32窗口显示调试信息,使用AllocConsole 函数 ]
- pvtrace和Graphviz实现对linux下C程序的函数调用跟踪
- J2ME程序开发要注意函数调用对性能的影响
- 微信小程序Page中data数据操作和函数调用
- 调用控制台应用程序并获得程序的输出信息
- 小程序的一些函数调用方法
- Linux调用backtrack函数打印程序崩溃时的调用堆栈
- Linux调用backtrack函数打印程序崩溃时的调用堆栈
- 用什么方法调用控制台程序,同时做到:1.隐藏控制台窗口;2.获取控制台程序的exit status
- C#调用参数为函数指针的API函数 - 以SetUnhandledExceptionFilter为例编写一个全局异常处理程序
- C++控制台程序调用C#的.dll文件
- 在C#中调用控制台程序
- 在Java程序中调用Matlab函数
- 在C程序中使用系统调用函数 rename()
- 使用CreateProcess函数实现隐秘的程序调用
- 如何在托管程序中动态加载dll并且调用其中的函数
- C#中调用控制台程序时隐藏控制台窗口
- HEVC/H.265整个程序调用流程分析以及函数复杂度分析 .
- linux下c程序调用reboot函数实现直接重启【转】
- 第二周【项目1】 编制三个程序,分别调用三个版本的交换函数,观察结果