lunedì 12 gennaio 2015

How to manage only one instance of a running executable with Qt framework

A typical issue is when you are dealing with an application in which we have to ensure that only a single instance of it is running on the current machine.
I've been doing C and C++ software development for many years especially under Windows and an efficient solution is the usage of a named mutex.
The problem is: this is not a cross-platform solution (or better, you can't write once, deploy everywhere).
Searching a solution in Internet I've found inYotube the channel of Brian Cairns (VoidRealMs, while his website is http://www.voidrealms.com/). He has produced more than 100 video tutorials about Qt framework and one of them is his solution to this problem (if you are Qt beginner I suggest you to spend some time ).
He used an IPC approach with QLocalServer / QLocalSocket.


I want to suggest a simpler solution based on QSharedMemory.
You will find an example on my GitHub account.

Nessun commento:

Posta un commento