Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is mutex user account specific?

In my application I create a mutex to avoid (why ever) to start the same (same == same path) exe twice.
Everything works fine if I start the process by myself (e.g. by explorer double click) twice. It means a second start can not create the mutex, because the mutex is already created by the first started process and so it does switch to the already started process.

Now I start the first instance of the process by a windows service, works fine, no problem. But when I start the same exe again by myself (explorer double click), the second started process can create the same mutex….

What I’m missing?

Thank you in advance.
Regadrs.
Posted
Updated 17-Jan-14 9:23am
v2

1 solution

I'm assuming you have this tagged right in C++ and not C#, but here is the documentation for CreateMutexEx http://msdn.microsoft.com/en-us/library/windows/desktop/ms682418(v=vs.85).aspx[^]. Notice the lpName parameter can have a prefix for Global or Local. This identifies what session the mutex applies to. I'm guessing that you need to use the global prefix in this case.
 
Share this answer
 
v3
Comments
SoMad 17-Jan-14 15:38pm    
Ron Beyer 17-Jan-14 15:42pm    
Thanks, I fixed it, for some reason selecting the word I want to link and pasting the link usually creates the right link, but it was mangling it in this case. I just posted the whole link, which is the same one you posted anyway.
[no name] 17-Jan-14 15:39pm    
Dear Ron
Thank you very much for your speedy response. Yes it is c++ and to be more precise, I'm using native WIN API.

The link you provided seems not to be valid :(
Regards, Bruno
Ron Beyer 17-Jan-14 15:41pm    
I fixed it, for some reason pasting it as a text link was mangling it.
[no name] 17-Jan-14 15:46pm    
Unfortunately I have to solve this in a Borland Builder 6 environment. I don't see that CreateMutexEx is available. Do you have a tip for this?

Thank you very much. Regards, Bruno

Sorry just recognized the meaning. I will try CreateMutex with prefix Global\

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900