Mainly use the Process class in the System.Diagnostics name space to implement
Thinking, we are looking for the process in the process before running the program, and the running position is also the same, if you don't run the program, if you have, you will place the same location in the same location.
Main code:
Public Static Process RunningInstance ()
{
Process Current = process.getcurrentProcess ();
Process [] processes = process.getProcesSbyName (current.ProcessName);
/ / Find the process of the same name
Foreach (Process Process In Processes)
{
// Ignore the current process
IF (Process.id! = Current.ID)
{
// Verify that the program running position of the same process is the same.
IF (Assembly.GetexecutingAssembly (). Location.Replace ("/", "//") == current.mainmodule.FileName)
{
// Return the Other process instance.
Return Process;
}
}
}
// no Other instance was found, return null.
Return NULL;
}