This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.
Do more with
void ForceCloseMutex(LPCTSTR pName) {
HANDLE hMutex = OpenMutex(MUTEX_ALL_ACCESS,FALSE,pName);
while(CloseHandle(hMutex));
}
// ...
BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved // reserved
) {
switch(fdwReason) {
// ...
case DLL_PROCESS_DETACH: ForceCloseMutex(_T("MyMutex"));
};
}
HANDLE ConnectMutex ( LPCTSTR pszName)
{
HANDLE hMutex = CreateMutex ( NULL,
FALSE,
FALSE,
pszName
);
if ( INVALID_HANDLE_VALUE == hMutex)
{
if ( ERROR_ALREADY_EXISTS == GetLastError ())
{
hMutex = OpenMutex ( SYNCHRONIZE,
FALSE,
pszName
);
if ( INVALID_HANDLE_VALUE == hMutex)
{
return NULL;
}
}
}
return hMutex;
}
Premium Content
You need an Expert Office subscription to comment.Start Free Trial