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.
Asked
Active
Viewed 1,764 times
1
-
http://stackoverflow.com/questions/19147/what-is-the-correct-way-to-create-a-single-instance-application http://elegantcode.com/2011/03/02/wpf-advanced-jump-lists-using-a-single-instance-application/ http://www.hanselman.com/blog/TheWeeklySourceCode31SingleInstanceWinFormsAndMicrosoftVisualBasicdll.aspx http://blogs.microsoft.co.il/blogs/maxim/archive/2010/02/13/single-instance-application-manager.aspx The above links describe how you can build single instance application – Ehsan Aleem Avee Oct 09 '12 at 05:22
-
My application was WPF (I should of mentioned that, sorry everyone else), so the second solution worked perfectly! Thank you very much. – Alexander Forbes-Reed Oct 09 '12 at 06:15
3 Answers
2
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.

Shiridish
- 4,942
- 5
- 33
- 64
0
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

vishal patel
- 71
- 4