Single instances?

S

sumsin

Hi,

How to create an applications that cannot have multiple instances
running on the same machine for the same user?

Thanks.
 
I

Ian Collins

sumsin said:
Hi,

How to create an applications that cannot have multiple instances
running on the same machine for the same user?
Try asking a a group dedicated to your OS, this isn't a language issue.
 
L

linarin

You can create a file in user's home directory act as mutex,and
testing file existence to see is there have an instance running.
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

You can create a file in user's home directory act as mutex,and
testing file existence to see is there have an instance running.

And hope your application does not crash before it deletes the file.
 
G

Ge Chunyuan

Hi,

How to create an applications that cannot have multiple instances
running on the same machine for the same user?

Thanks.

right depends on the OS.
Like windows, maybe you can add flag in register table.
Check the flag once run the ap.
 
J

James Kanze

Implement signal handler to catch signals and delete file before
aborting.

You can't catch all signals, and theoretically, at least, you
can't call remove() from a signal handler (although I think it
will work under both Unix and Windows).

The classical solution is either to ask the user when you find
the file, and let him decide if you start anyway, at his risks
and perils, or to write the process id into the file, and when
you find it on start-up, read the process id, then ask the
system (very system dependant) if such a process is still
running.
 
A

Amal P

Hi,

How to create an applications that cannot have multiple instances
running on the same machine for the same user?

Thanks.

Dear Susmin,

One method is that by creating a named mutex.
If you are using mutex. Just refer to CreateMutex API.
You create a mutex in the constructor and RelaseMutex in the
destructor.
When you create the mutex if it tells that the mutex is already
created abort your program from constructor itself.

Thanks and regards,
Amal P.
 

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

Forum statistics

Threads
474,292
Messages
2,571,495
Members
48,185
Latest member
abhaysingh01

Latest Threads

Top