Does anyone knows how to "disable multiple instances of application"?!

V

Victor Bazarov

Somebody in the newsgroup for your platform should know. C++ has no
concept of "application". A C++ program (from the C++ point of view)
is a single thread running on a single processor. Multiple processes,
multiple "instances" of application, are all foreign concepts to C++,
usually provided by the OS.

V
 
R

Raymond Martineau

At best, you could try to use the File I/O to create a file, and use the
presence of that file as a presence of another instance (and even then,
it's not a reliable method.) Otherwise, you need to ask the newsgroup
associated with the platform you are running.
 
G

Gianni Mariani

There is no way of "disabling" multiple instances of an application.

What most programs that require this behaviour do is use a system
specific mechanism to detect wether the "application" is currently
running and initiate a communication with the other instance to "take over".

One method commonly used is to create a locking file that is kept open
by the application and "locked" (again off topic here) so that if the
application is shut down improperly, it will be automatically be
unlocked by the operating system. Communication can be done using a
named pipe, socket or any other favorite IPC mechanism you want, all
off-topic here.

Nontheless, the code is quite trivial.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top