简体   繁体   中英

Open new instance of C# windows application

I am working in windows environment and I need to open a new instance of my application programmatically while running the application is that possible?

I am greatly appreciative of any guidance or help.

Try this:

var info = new System.Diagnostics.ProcessStartInfo(Application.ExecutablePath);
System.Diagnostics.Process.Start(info );
System.Diagnostics.Process.Start(Application.ExecutablePath);

对于Winforms应用程序。

You could use the Process.Start method:

Process.Start(@"c:\work\myapp\foo.exe");

and if your application needed to take arguments:

Process.Start(@"c:\work\myapp\foo.exe", "-a arg1 -b arg2");

You can start any application using the Process.Start() method.

But depending on what you want to do, it might be better to directly use classes from your one of your applications to eg . open window that's in another application.

Sure! You have create a new istance of your main project class!

You have to create a reference to your project and then you can create your main form istances!

Updated

My mistake! I've understand that you have to call a second existing application from a first one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM