By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,707 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Single instances?

P: n/a
Hi,

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

Thanks.

Jun 14 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
sumsin wrote:
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.

--
Ian Collins.
Jun 14 '07 #2

P: n/a
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.

Jun 14 '07 #3

P: n/a
On 14 Juni, 07:34, linarin <lin.jian...@gmail.comwrote:
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.

--
Erik Wikström

Jun 14 '07 #4

P: n/a
On Jun 14, 11:12 am, Erik Wikström <eri...@student.chalmers.sewrote:
On 14 Juni, 07:34, linarin <lin.jian...@gmail.comwrote:
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.
Implement signal handler to catch signals and delete file before
aborting.
>
--
Erik Wikström

Jun 14 '07 #5

P: n/a
On Jun 14, 12:30 pm, sumsin <sumsin...@gmail.comwrote:
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.

Jun 14 '07 #6

P: n/a
On Jun 14, 8:45 am, "somnath...@gmail.com" <somnath...@gmail.com>
wrote:
On Jun 14, 11:12 am, Erik Wikström <eri...@student.chalmers.sewrote:
On 14 Juni, 07:34, linarin <lin.jian...@gmail.comwrote:
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.
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.

--
James Kanze (GABI Software, from CAI) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Jun 14 '07 #7

P: n/a
On Jun 14, 1:30 pm, sumsin <sumsin...@gmail.comwrote:
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.

Jun 14 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.