Unfortunately MFC don't provide any APIs. However, there is the simplest method by MUTEX.
First, you create the globally unique identifier (GUID) to create MUTEX.
MFC provides creating GUID: Tools-Create GUID.
after creating it, just copy and paste in your code.
The following code located in InitInstance() of MFC.
CString stringGUID = L"........";
HANDLE hMutex = CreateMutex(NULL, TRUE, stringGUID);
if( GetLastError() == ERROR_ALREADY_EXISTS )
{
CloseHandle(hMutex);
return FALSE;
}
No comments:
Post a Comment