1

Topic: OpenMutex in Windows 7 vs 10

Long picked  and, like, solved a question. But a crutch. It would be desirable to understand how now to live we Have the process starting as admin and doing the following: mutex = CreateMutex (NULL, TRUE, name);//some processing ReleaseMutex (mutex); And the process starting after first all the same as (the normal user or as admin): mutex = OpenMutex (SYNCHRONIZE | MUTANT_QUERY_STATE, FALSE, name);//... DWORD res = WaitForSingleObject (mutex, INFINITE);//... ReleaseMutex (mutex) All works perfectly in Windows 10, 7 (at itself checked). But suddenly users with problems in 7 started to appear. Clarified that in the second process Wait it is hung up forever. That is, mutex it is opened, errors are not present, but  it we can not. The crutch looks so://if Windows 7 mutex = CreateMutex (NULL, FALSE, name); I somewhere not so made something or what?

2

Re: OpenMutex in Windows 7 vs 10

Hello, CyberDemon, you wrote: CD>...> I something somewhere not so made CD or what? Check of errors everywhere is? Whether I.e. that CreateMutex and OpenMutex return NULL It is checked after successful CreateMutex that this creation new , instead of discovery already existing (i.e. that GetLastError ()! = ERROR_ALREADY_EXISTS)? If this discovery ReleaseMutex it is impossible to do since not we captured it. I.e. more exact sequence of actions approximately the such: we Cause CreateMutex with a flag bInitialOwner = TRUE. If success, we cause GetLastError (). If there ERROR_ALREADY_EXISTS, means,  already exists, it is necessary to do WaitForSingleObject and to wait, while it will be released. And only when it will be released, it is possible to perform the operation and then to release it through ReleaseMutex. The second application does about the same, only at it OpenMutex instead of CreateMutex (though actually CreateMutex it is possible both there, and there).

3

Re: OpenMutex in Windows 7 vs 10

Hello, okman, you wrote: O> Hello, CyberDemon, you wrote: CD>>...>> I something somewhere not so made CD or what? O> Check of errors everywhere is? I.e. that CreateMutex and OpenMutex return not NULL Yes, of course, it is all it is checked. And before Wait on NULL too check is. Whether O> It is checked after successful CreateMutex that this creation new , and O> not discovery already existing (i.e. that GetLastError ()! = ERROR_ALREADY_EXISTS)? O> If this discovery ReleaseMutex it is impossible to do since not we captured it. O> I.e. more exact sequence of actions approximately the such: the Main application (which administrator) creates the first mutex, it in system cannot be. O> we cause CreateMutex with a flag bInitialOwner = TRUE. O> If success, we cause GetLastError (). If there ERROR_ALREADY_EXISTS, means, O>  already exists, it is necessary to do WaitForSingleObject and to wait, while O> it will be released. And only when it will be released, it is possible to perform the operation and O> then to release it through ReleaseMutex. Though also an unreal situation, but I  will try.

4

Re: OpenMutex in Windows 7 vs 10

Hello, okman, you wrote: Once again re-read the first message and understood that, probably, I a little crookedly wrote about a crutch. CreateMutex without InitialOwner = FALSE I do in the second process. And the first all as with TRUE. That is, CreateMutex instead of OpenMutex is and there is a crutch.

5

Re: OpenMutex in Windows 7 vs 10

Hello, CyberDemon, you wrote: CD> (which administrator) the first creates the Main application mutex, it in system cannot be. The main application could not be launched or die (or to close )

6

Re: OpenMutex in Windows 7 vs 10

Hello, IID, you wrote: IID> the main application could not be launched or die (or to close ) If the core is not launched, "client" will not be launched also. Specificity. Close ahead of time it it cannot. It is exact. Can die, but it already other question and this situation, it is obviously, easily watched.