i have been trying the code using mutex but im unable to open my exe after button click im successful in not making the multiple entries of the application on the taskbar at button click but my application is launched only when i close my form.. i want to launch my application on button click and if the application is already launched then i need to focus on the previous running application.. how could i able to resolve my need to launch as well as focusin and reopening that application again.. im sending u my code that im using on button click event and plz modify my errors...
coding at program.cs
static void Main() {
Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); System.Diagnostics.Process.Start("filename.exe");
} :
coding done at form1.cs
:
private void button1_Click(object sender, EventArgs e) {
try
{
bool createdNew;
Mutex m = new Mutex(true, "e-Recording", out createdNew);
System.Diagnostics.ProcessStartInfo f = new System.Diagnostics.ProcessStartInfo("C:\\windows\\system32\\rundll32.exe", "C:\\windows\\system32\\shimgvw.dll,ImageView_Fullscreen " + "filename.exe".TrimEnd(null));
if (createdNew) Launch();
else
{
MessageBox.Show("e-Recording is already running!", "Multiple Instances");
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
} }