Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: foobar's mutex (Read 4320 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

foobar's mutex

I've learned that foobar creates a named mutex, which I want to use to check if foobar is running (which is more reliable than using the classname). However, it seems each foobar installation appends a random string to the mutex, e.g. "FOOBAR2000_01234567", where "01234567" is an uppercase hexadecimal random string (all in unicode). Where does this string come from? Is there a way to calculate it?

Thanks in advance.

foobar's mutex

Reply #1
Undocumented features of the core are not to be relied upon. They may change at any time without notice.

foobar's mutex

Reply #2
I see. How about making the mutex a documented feature then, or introducing an additional mutex with a common name across all installed instances? As the classname can be changed, this seems like the best way to detect running instances of foobar.

foobar's mutex

Reply #3
And why do you need to do that? If you have your own component which can communicate with external software, why not write your own mechanism for detecting a running installation? What is it you desire?

foobar's mutex

Reply #4
I'm writing an installer for a foobar component. If the user installs the component while foobar is running, the installer will fail to replace an existing version of the component. So I'd like to remind the user that he needs to shut down foobar before the installation can continue (or else he will have to restart whole Windows to get the file replaced). As the installer (Inno Setup; I dislike NSIS) already has a built-in CheckMutex feature for that purpose, using a mutex seems the cleanest solution.

What do you mean by "why not write your own mechanism for detecting a running installation", by the way? That's exactly what I'm doing, and the best way to detect a running installation is to check against a mutex. All other methods (e.g. checking the window / class name) are not fool-proof.

foobar's mutex

Reply #5
Why do you need to make an installer for a component? Why can't you just distribute the dll file(s)?

foobar's mutex

Reply #6
Of course I could distribute only the DLL(s), but that won't solve the issue that you can't replace a component while foobar is running. Still, for advanced users, this might be the prefered solution. But as my component does not only consist of a single DLL for foobar, but also contains plug-ins for other applications (it builds a bridge between foobar and these applications), many users have asked for an installer to simplify the setup.

foobar's mutex

Reply #7
Perhaps a more generic solution would be useful. The installer for TortoiseSVN detects applications that currently use files it wants to update. It displays this list and asks the user to close them.