C#调用外部程序

来源:百度知道 编辑:UC知道 时间:2024/06/11 22:54:58
如何利用C#调用外部程序的某个控件或者菜单而不出现外部程序的应用界面 代码是怎么样的?谢谢各位!!!

这个是调用系统cmd的语句看看吧
public void OpenCmd(string ServerName , string UserName ,string Pass )
{
Process info = new Process();
info.StartInfo.FileName = @"c:\Windows\System32\cmd.exe";
info.StartInfo.WorkingDirectory = @"C:\";
info.StartInfo.UseShellExecute = false;
info.StartInfo.RedirectStandardInput = true; //重定向标准输入
info.StartInfo.RedirectStandardOutput = true; //重定向标准输出
info.StartInfo.RedirectStandardError = true; //重定向错误输出
info.StartInfo.CreateNoWindow = false;
info.Start();

string path = @"net use \\"+ ServerName+ textBox1.Text +@"LCAPP /User:"+ UserName +" "+ Pass+"";
info.StandardInput.WriteLine(path);
info.StandardInput.WriteLine("Exit");