1
我想将我的应用程序的新实例的命令行参数传递给已经运行的实例(如果存在的话)。到目前为止,我已经试过如下:将命令行参数传递给已运行的应用程序实例
Program.cs的
string[] Arguments = Environment.GetCommandLineArgs();
int iCurrentProcessID = -1;
using (Mutex mutex = new Mutex(true, Arguments[1], out createdNew)) //Finding if application is running or not
{
Process current = Process.GetCurrentProcess();
iCurrentProcessID = current.Id;
if (createdNew)
{
Application.Run(Frm1);
}
else
{
// Process current = Process.GetCurrentProcess();
Process CurrentAutomation = Process.GetProcessById(iCurrentProcessID);
string[] strArguments = Environment.GetCommandLineArgs();
if (!string.IsNullOrWhiteSpace(strArguments[2]))
{
frmMain.strEndtime = strArguments[2];
}
Form.cs
public partial class frmMain : Form
{
public static string strEndtime;
//...
}
值在二审正确设置,但没有设置在第一个(开始较早)之一。我如何将这些值传递给我的应用程序的其他实例?
你想要做什么?你是否想要将第一个应用程序实例的属性值设置为第二个实例的参数? – slawekwin
我想在第一个实例中使用第二个实例。 – Babu
尝试搜索类似“C#传递参数运行应用程序”,例如[this](http://stackoverflow.com/questions/3793997/pass-arguments-to-running-application)可能有帮助 – slawekwin