473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Single instances?

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
7 1178
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pure Krome | last post by:
How do i serialize two instances (of some object) in the same class? I'm not sure how i would de-serialize a class that has two or more instances of some object type, and how the deserialize...
0
by: v I n O | last post by:
hI Geeks Please do let me know how do i find how many instances sql server running on the single machine. or in the n/w my objective should with help of C#/vb.net
3
by: kathy | last post by:
I have a general question. If I write a application using any language(C/C++/C#/VB). How to make sure it only has one instance running? What I need to write in source code? If multi-instances...
3
by: Bill | last post by:
I have a seating chart web form that has over 50 entry field controls (tables/booths) where I use a DropDownList box to select a single company name from a single large list of organizations (200...
4
by: Jeff | last post by:
We have multiple ASP.Net web apps in development. As a standard we are looking to go with SQL Server to hold state information. Can we have the multiple apps all point to a single State DB? Or...
6
by: buffinator | last post by:
I have two applications that should work together, let's call them A and B. The first time A starts, it should open a B process and start communicating with it. All other times an A instance...
13
by: JohnQ | last post by:
Why would anyone write: class SomeThing // class littered with non-domain single-instancing code :( { private: SomeThing(); static SomeThing* pInstance_; public: static SomeThing*...
3
by: sklett | last post by:
I suspect the answer might be in one of the words of my subject, but here goes anyway. I'm working on a system that will execute a very long (300+) chain of task objects. Here is some quick...
7
by: =?Utf-8?B?YWVzcGVy?= | last post by:
Is there such a thing as a single instance web service? Is it possible to have all calls to a web service share one property value by declaring it as static? I know web service should be stateless,...
10
by: Peter Morris | last post by:
Some time ago I needed to write a single-instance app. That's an easy task but I also needed duplicate instances to pass their command line parameters to the first instance so that it can act upon...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.