Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 621365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:51:58+00:00 2026-05-13T18:51:58+00:00

i have been trying the code using mutex but im unable to open my

  • 0

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());
     }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:51:59+00:00Added an answer on May 13, 2026 at 6:51 pm

    This is be able to find and switch to an already running process that matches what you are trying to start.

    [DllImport( "user32.dll" )]
    public static extern bool ShowWindowAsync( HandleRef hWnd, int nCmdShow );
    public const int SW_RESTORE = 9;
    
    public void SwitchToCurrent() {
      IntPtr hWnd = IntPtr.Zero;
      Process process = Process.GetCurrentProcess();
      Process[] processes = Process.GetProcessesByName( process.ProcessName );
      foreach ( Process _process in processes ) {
        // Get the first instance that is not this instance, has the
        // same process name and was started from the same file name
        // and location. Also check that the process has a valid
        // window handle in this session to filter out other user's
        // processes.
        if ( _process.Id != process.Id &&
          _process.MainModule.FileName == process.MainModule.FileName &&
          _process.MainWindowHandle != IntPtr.Zero ) {
          hWnd = _process.MainWindowHandle;
    
          ShowWindowAsync( NativeMethods.HRef( hWnd ), SW_RESTORE );
          break;
        }
      }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using python to code. I have been trying to webscrape the names,
I have been trying to generate a QR code using Zxing. Following the minimal
Hey, I have been trying to switch my code from using an ie object
I'm using Entity Framework 4.1 Code First and have been trying to add a
In MATLAB, vectorized code is faster than using for-loops. I have been trying to
I have been trying to find a solution for past few hours but unable
i have been trying to set a image on a button using the following
I have been trying to display image from database using php but i am
Below is my code and I have been trying to color the cells but
I have been trying to write some code in Scala to read a file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.