Use c # To develop an application. Sometimes you only need to enable the application once ..
Three methods can be implemented. If you have any good methods, let's discuss them ..
// ===== Create a mutex method: ====
// Bool blnIsRunning;
// Mutex mutexApp = new Mutex (false, Assembly. GetExecutingAssembly (). FullName, out blnIsRunning );
// If (! BlnIsRunning)
//{
// MessageBox. Show ("the program is running! "," Prompt ",
// MessageBoxButtons. OK, MessageBoxIcon. Exclamation );
// Return;
//}
// Ensure that only one client is running
// System. Threading. Mutex mutexMyapplication = new System. Threading. Mutex (false, "OnePorcess.exe ");
// If (! MutexMyapplication. WaitOne (100, false ))
//{
// MessageBox. Show ("program" + Application. ProductName + "already running! ", Application. ProductName,
// MessageBoxButtons. OK, MessageBoxIcon. Error );
// Return;
//}
// ====== Process method: (execution can still be performed after the program name is modified) ====
// Process current = Process. GetCurrentProcess ();
// Process [] processes = Process. GetProcessesByName (current. ProcessName );
// Foreach (Process process in processes)
//{
// If (process. Id! = Current. Id)
//{
// If (process. MainModule. FileName
// = Current. MainModule. FileName)
//{
// MessageBox. Show ("the program is running! ", Application. ProductName,
// MessageBoxButtons. OK, MessageBoxIcon. Exclamation );
// Return;
//}
//}
//}
You only need to put the required method code in the Void Main () method ..