views:

175

answers:

3

I need to make so that my application can have only one instance running at a time. Also when it's launched with a command line parameter ( like when registered to open certain file types ) it should pass the parameter to an existing instance and quit immediately without displaying graphical interface. You all probably know what I mean. The framework used is Qt 4, and it seems like it must have some facilities for that. Any ideas?

+3  A: 

There is a Qt Solutions project doing this:

Qt Single Application

ashcatch
A: 

It's also possible to implement a this sort of class oneself using QSharedMemory (see QSharedMemory::attach() ). It's capable of being used for both determining whether other instance is already running and communicating/sending messages. Except some pointer magic and memory copying it's quite straightforward.

Maleev
+1  A: 

There are several ways to do inter process communication. Examples can be found in Qt's examples section.