1. Add a variable in the CWINAPP class
Handle hmutex;
2. Add the following code in InintInstance ():
CString szclassname = "shutdown";
HMutex = OpenMuteX (Mutex_all_Access, False, SzclassName);
IF (hmutex == null)
HMutex = Createmutex (Null, True, SzclassName);
Else
{
Messagebox (0, "program has been opened, can't run! / T", "Warning", MB_ok | MB_ICONERROR);
Return False;
}
3. Add the following code in ExitInstance ():
IF (hmutex! = NULL)
ReleaseMutex (HMUTEX);