您的位置:首页 > 其它

通过Process调用桌面程序

2012-02-02 14:47 405 查看
通过Process调用桌面程序

View Code

1 private void Form1_Load(object sender, EventArgs e)
2 {
3 string userid = "admin";
4 string password = "00";
5 string[] cmd = new string[] { @"cd E:\Project\DotNet\bin\Debug", "PhotoMan.exe $StartFromEIP$ " + userid + " " + assword };
6
7 Process p = new Process();
8 p.StartInfo.FileName = "cmd.exe";
9 p.StartInfo.UseShellExecute = false;
10 p.StartInfo.RedirectStandardInput = true;
11 p.StartInfo.RedirectStandardOutput = true;
12 p.StartInfo.RedirectStandardError = true;
13 p.StartInfo.CreateNoWindow = true;
14 p.Start();
15 p.StandardInput.AutoFlush = true;
16 for (int i = 0; i < cmd.Length; i++)
17 {
18 p.StandardInput.WriteLine(cmd[i].ToString());
19 }
20 p.StandardInput.WriteLine("exit");
21 string strRst = p.StandardOutput.ReadToEnd();
22 p.WaitForExit();
23 p.Close();
24 Form1_FormClosed(null, null);
25
26 }
27
28 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
29 {
30 Application.Exit();
31 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: