I have a DLL which creates like this:
HANDLE hMutex = ::CreateMutex(NULL,FALSE, "Testing");
I have program which loads this DLL:
HMODULE test = LoadLibrary("MyDLL.dll");
Now I do this check AFTER! FreeLibrary:
HANDLE hMutex = ::CreateMutex(NULL,FALSE, "c14");
if (hMutex != NULL)
if(GetLastError() == ERROR_ALREADY_EXISTS)
MessageBox(0, "Already Loaded!", "Loaded!", 64);
MessageBox(0, "NOT Loaded!", "NOT Loaded!", 64);
Always I get already loaded!
I don't want it, I want to lose Mutex when MyDLL is unloaded... How to accomplish this? FreeLibrary doesn't remove DLL from memory?
Please advice... Even if you better method for detection of loaded/unloaded DLL please advice... I don't want to use CreateWindow method, but if I have to use, I'll use...