The following code works without any problem sometimes and at other times it throws “Access is denied” error. The behavior is not consistent.
_hMutex = CreateMutex(NULL, FALSE, MutexName);
if (_hMutex == NULL)
{
throw MY_ERROR(GetLastError(), L"Error creating mutex handle");
}
I run my standalone executable which has this code, do the operation and exit. It is not a multithreaded application. I logon with the same user credential every time I run this.
Could you help me resolve this?
Thanks,
Hem
I found it finally. There is a service that runs with system account that creates the mutex and an exe run by user trying to access it. It was due to the permission.