首页 技术 正文
技术 2022年11月9日
0 收藏 555 点赞 2,326 浏览 855 个字

1. 如果exe文件的返回值是int类型,标识操作执行的结果是否成功,例如:

class Program

{

static int Main(string[] args)

{

return args.Length;

}

}

则在调用exe文件时,可以用如下方法:

Process myProcess = new Process();

string fileName = @”C:/Test.exe”;

string para =@”你好 北京欢迎你!”;

ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(fileName, para);

myProcess.StartInfo = myProcessStartInfo;

myProcess.Start();

while (!myProcess.HasExited)

{

myProcess.WaitForExit();

}

int returnValue = myProcess.ExitCode;

2. 如果exe文件是将输出内容写入标准流,例如:

class Program

{

static void Main(string[] args)

{

Console.Write(args[0] + args[1] + args [2]);

}

}

则在调用exe文件时,可以用如下方法:

string fileName = @”C:/Test.exe”;

Process p = new Process();

p.StartInfo.UseShellExecute = false;

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.FileName = fileName;

p.StartInfo.CreateNoWindow = true;

p.StartInfo.Arguments = “你好, 北京 欢迎你!”;//参数以空格分隔,如果某个参数为空,可以传入””

p.Start();

p.WaitForExit();

string output = p.StandardOutput.ReadToEnd();

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,089
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,566
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,415
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,187
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,823
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,906