C# 应用程序间传值的小问题 在一个应用程序A中启动另一个应用程序B,要把A中的参数stringItem传给B,在B的一个textbox中显示。我用Process.Start(senderLocation, stringItem);启动B并传值。请问如何在B中接收这个参数stringItem呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 分布式编程利用Tcp 或者 Http通道来传递远程对象 具体应该怎么做呢?能给出代码吗?这个应该很简单吧。网上有类似问题,不同应用程序都是用Process.Start(yourApp)来启动。传递参数的话只要用Process.Start(yourApp,parameter)来启动,但是没有说明在yourApp应用程序中如何使用parameter这个参数。 1private void runSyncAndGetResults_Click(object sender, System.EventArgs e) 2{ 3 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:\listfiles.bat"); 4 psi.RedirectStandardOutput = true; 5 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 6 psi.UseShellExecute = false; 7 System.Diagnostics.Process listFiles; 8 listFiles = System.Diagnostics.Process.Start(psi); 9 System.IO.StreamReader myOutput = listFiles.StandardOutput; 10 listFiles.WaitForExit(2000);11 12 if (listFiles.HasExited) 13 { 14 string output = myOutput.ReadToEnd(); 15 this.processResults.Text = output; 16 }17}第二个程序是个控制台程序,输出在控制台上显示的字符串. 1private void runSyncAndGetResults_Click(object sender, System.EventArgs e) 2{ 3 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:\listfiles.bat"); 4 psi.RedirectStandardOutput = true; 5 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 6 psi.UseShellExecute = false; 7 System.Diagnostics.Process listFiles; 8 listFiles = System.Diagnostics.Process.Start(psi); 9 System.IO.StreamReader myOutput = listFiles.StandardOutput; 10 listFiles.WaitForExit(2000);11 12 if (listFiles.HasExited) 13 { 14 string output = myOutput.ReadToEnd(); 15 this.processResults.Text = output; 16 }17}主义,这个例子里面的被启动的 .net Remoting是可以的google一些资料看看吧 我在A进程中用Process.Start(yourApp,parameter)来启动进程B后,在B进程里用ProcessStartInfo psi = new ProcessStartInfo(); string senderLocation = psi.Arguments;为什么无法得到传进来的parameter参数?我还是想用Process.Start(yourApp,parameter)来传参数,这样可以在我原来代码的基础上改动最少。大家说说看呢。 在B程序中,找到static void Main(), 然后稍加改动即可: static void Main(String[] args) // <---------加String[] args { //... MessageBox.Show(string.Join("\n", args)); // <---------加一行显示 Application.Run(new Form1()); } TCP长连接如何设置一个监控线程 母板页怎么把它分成左右2个页面 c# iis问题 各自报一下各地的基本工资(C#开发)好吗?参考一下。 控制台程序的标题,用C的话可用system("title abc")更改,不知C#如何才能? 计算数据库排名的问题 doc88分析结果供大家参考 从摄像机得到了数据,如果以bmp形式保存在内存里 关于C#中timer的用法 EF6 中的 来自数据库的Code First (DBCodeFirst)如果更新?(新增表或者修改字段) 请问Socket用TcpClient发送完消息后,如何释放本地端口? 如何获取/设置子容器中控件的焦点?
利用Tcp 或者 Http通道来传递远程对象
这个应该很简单吧。网上有类似问题,不同应用程序都是用Process.Start(yourApp)来启动。
传递参数的话只要用Process.Start(yourApp,parameter)来启动,但是没有说明在yourApp应用程序中如何使用parameter这个参数。
2{
3 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:\listfiles.bat");
4 psi.RedirectStandardOutput = true;
5 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
6 psi.UseShellExecute = false;
7 System.Diagnostics.Process listFiles;
8 listFiles = System.Diagnostics.Process.Start(psi);
9 System.IO.StreamReader myOutput = listFiles.StandardOutput;
10 listFiles.WaitForExit(2000);
11
12 if (listFiles.HasExited)
13 {
14 string output = myOutput.ReadToEnd();
15 this.processResults.Text = output;
16 }
17}
第二个程序是个控制台程序,
输出在控制台上显示的字符串.
2{
3 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:\listfiles.bat");
4 psi.RedirectStandardOutput = true;
5 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
6 psi.UseShellExecute = false;
7 System.Diagnostics.Process listFiles;
8 listFiles = System.Diagnostics.Process.Start(psi);
9 System.IO.StreamReader myOutput = listFiles.StandardOutput;
10 listFiles.WaitForExit(2000);
11
12 if (listFiles.HasExited)
13 {
14 string output = myOutput.ReadToEnd();
15 this.processResults.Text = output;
16 }
17}
主义,这个例子里面的被启动的
google一些资料看看吧
string senderLocation = psi.Arguments;为什么无法得到传进来的parameter参数?我还是想用Process.Start(yourApp,parameter)来传参数,这样可以在我原来代码的基础上改动最少。大家说说看呢。
在B程序中,找到static void Main(), 然后稍加改动即可:
static void Main(String[] args) // <---------加String[] args
{
//...
MessageBox.Show(string.Join("\n", args)); // <---------加一行显示
Application.Run(new Form1());
}