Reputation: 2975
I have it set so if you open a file, it launches my application and adds it to the start-up arguments. But how can I make it so if I double click on a file it loads it in the application that's already running? Rather than loading each file into it's own instance of the application.
Upvotes: 1
Views: 1866
Reputation: 4962
Mutex is want you need to have a single instance of the application.
bool createdNew = true;
using (Mutex mutex = new Mutex(true, "MyApplicationName", out createdNew))
{
if (createdNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
You can refer this LINK for detailed information.
Upvotes: 2
Reputation: 71
use mdiParent and child forms in C# I think it's great feature of vs C#
for more inforamtion: http://msdn.microsoft.com/en-us/library/d4dabts7%28v=vs.80%29.aspx
Upvotes: 0