473,396 Members | 1,738 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,396 software developers and data experts.

Single Instance

Hi there,

I am looking for a way to prevent my application from starting again
if it is already running. Is there a way I can ask Windows if it is?

Thanx....
Nov 20 '05 #1
8 1481
Get a list of processes from System.Diagnostics.Process and see if the app
is running.

-CJ
"Pepi Tonas" <Pe*******@hotmail.com> wrote in message
news:d5********************************@4ax.com...
Hi there,

I am looking for a way to prevent my application from starting again
if it is already running. Is there a way I can ask Windows if it is?

Thanx....

Nov 20 '05 #2
Or you can use a mutex:
http://www.codeproject.com/vb/net/sing_inistan.asp

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"Pepi Tonas" <Pe*******@hotmail.com> schreef in bericht
news:d5********************************@4ax.com...
Hi there,

I am looking for a way to prevent my application from starting again
if it is already running. Is there a way I can ask Windows if it is?

Thanx....

Nov 20 '05 #3
* Pepi Tonas <Pe*******@hotmail.com> scripsit:
I am looking for a way to prevent my application from starting again
if it is already running. Is there a way I can ask Windows if it is?


Nice solution by Tom Shelton:

<http://groups.google.com/groups?selm=eJCwBK%23PDHA.1608%40TK2MSFTNGP11.phx. gbl>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Every time I see this question, I think to myself... What if the application
is running under Terminal Server AND you want it to be once per Logged In
User session instead of once per machine...

What is the best way to do this?

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eF****************@TK2MSFTNGP12.phx.gbl...
* Pepi Tonas <Pe*******@hotmail.com> scripsit:
I am looking for a way to prevent my application from starting again
if it is already running. Is there a way I can ask Windows if it is?
Nice solution by Tom Shelton:

<http://groups.google.com/groups?selm...2MSFTNGP11.phx.
gbl>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #5
"Jim Hughes" <NO*********@HotMail.com> wrote in message <news:e1**************@tk2msftngp13.phx.gbl>...
Every time I see this question, I think to myself... What if the application
is running under Terminal Server AND you want it to be once per Logged In
User session instead of once per machine...

What is the best way to do this?


If it's easy to fetch the user's SID or domain and username, make
those part of the mutex name? What would be nice is if the same
set of techniques could be used to deal with both Terminal Server
and XP's fast user-switching, since the issues are similar. =)

--
Joe Foster <mailto:jlfoster%40znet.com> Sacrament R2-45 <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above They're coming to
because my cats have apparently learned to type. take me away, ha ha!
Nov 20 '05 #6
Thanks for the reply - good ideas!

I thought about the XP - Fast User question right after I posted, but I'm
almost always in domain environments and not workgroups.

I also found this article after posting - while not specific to my question
it added relevant info to the subject!

http://www.codeproject.com/vb/net/sing_inistan.asp

"Joe "Nuke Me Xemu" Foster" <jo*@bftsi0.UUCP> wrote in message
news:eh**************@TK2MSFTNGP10.phx.gbl...
"Jim Hughes" <NO*********@HotMail.com> wrote in message <news:e1**************@tk2msftngp13.phx.gbl>...
Every time I see this question, I think to myself... What if the application is running under Terminal Server AND you want it to be once per Logged In User session instead of once per machine...

What is the best way to do this?
If it's easy to fetch the user's SID or domain and username, make
those part of the mutex name? What would be nice is if the same
set of techniques could be used to deal with both Terminal Server
and XP's fast user-switching, since the issues are similar. =)

--
Joe Foster <mailto:jlfoster%40znet.com> Sacrament R2-45

<http://www.xenu.net/> WARNING: I cannot be held responsible for the above They're coming to because my cats have apparently learned to type. take me away, ha ha!

Nov 20 '05 #7
http://www.bobpowell.net/singleinstance.htm

--
Bob Powell

Get a free issue of Well Formed VB edition.
http://www.bobpowell.net/vb_offer.htm

What's Well Formed?
http://www.bobpowell.net/currentissue.htm

Visit the GDI+ FAQ for articles, tips, tricks and code.
http://www.bobpowell.net/gdiplus_faq.htm

Read my blog
http://bobpowelldotnet.blogspot.com


"Pepi Tonas" <Pe*******@hotmail.com> wrote in message
news:d5********************************@4ax.com...
Hi there,

I am looking for a way to prevent my application from starting again
if it is already running. Is there a way I can ask Windows if it is?

Thanx....

Nov 20 '05 #8
* "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> scripsit:
http://www.bobpowell.net/singleinstance.htm


Basically that will work, but if your application has a "common" name
like "Calculator", it may not work if an other application with the same
name (which is not an instance of your application) is running.

Just a thought...

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Elad | last post by:
Hi, I have an application that is made up of several executables. I need all these executables to use the same instance of an object. What is the best, most efficient way to approach this? ...
18
by: Steve Barnett | last post by:
I want to ensure that there is only ever one instance of my app running on a single PC at any time. I understand that I can achieve this by using a mutex and, if I can't take ownership of the...
7
by: jsale | last post by:
I have made an ASP.NET web application that connects to SQL Server, reading and writing data using classes. I was recommended to use session objects to store the data per user, because each user...
1
by: Maileen | last post by:
Hi, How can i do (and test) a single instance of my form ? thanks, Maileen
9
by: MrSpock | last post by:
1. Create a new Windows Application project. 2. Open the project properties and check "Make single instance application". 3. Build. 4. Go to the release folder and run the application. 5. Try to...
3
by: sadanjan | last post by:
Hi , Appreciate if someone can clarify if database Share Memory Limit (2 GB ) in Unix 32 bit boxes is the top limit for all the databases put together in a database or is it for each of the...
3
by: Mark Jerde | last post by:
VS 2005. When I google "CSharp single instance form" the returned pages usually use a Mutex or the VB.NET runtime library....
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...
5
by: Sarath | last post by:
I've to write a single instance class. there are different methods to control the single instance of a program. I've tried the following method class CSingleton { public: CSingleton&...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.