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

Checking if running

Hey Group,

How would I check if my Application is running on a local PC and if it is
throw a message to say its already running and quit the the second instance?

Many Thanks
MCN
Nov 20 '05 #1
4 785
Hi MS,

This is the very simple solution from this.
\\\
Private mut As New Threading.Mutex(True, "myProg", mutCreated)
)
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not mutCreated Then Me.Close()
///
But remember that when you use this, and there can be a complete other
program with the same name as yours, that program can also not start.

Better
Single instance mostly C# code
http://msdn.microsoft.com/library/de...eaworapps1.asp

I hope this helps?

Cor
Nov 20 '05 #2
* "MadCrazyNewbie" <te**@nospam.com> scripsit:
How would I check if my Application is running on a local PC and if it is
throw a message to say its already running and quit the the second instance?


For example, in your 'Sub Main':

\\\
Dim m As Mutex = _
New Mutex(False, "{11C92606-65D9-4df2-9AEA-B6A4DA91BCE2}")
If m.WaitOne(10, False) Then
Application.Run(New Form1())
m.ReleaseMutex()
Else
MessageBox.Show("Anwendung wird bereits ausgeführt!")
End If
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Hi MS,

It is almost the same as the solution i did give you however this signature
from your program is of course better, (Herfried, can that not direct?, you
know that direct and I have to search how.)
New Mutex(False, "{11C92606-65D9-4df2-9AEA-B6A4DA91BCE2}")
However I think that this will give you on a lot of places in the world very
much respect MessageBox.Show("Anwendung wird bereits ausgeführt!")


:-))

Cor
Nov 20 '05 #4
* "Cor Ligthert" <no**********@planet.nl> scripsit:
It is almost the same as the solution i did give you however this signature
from your program is of course better, (Herfried, can that not direct?, you
know that direct and I have to search how.)
New Mutex(False, "{11C92606-65D9-4df2-9AEA-B6A4DA91BCE2}")

The difference is that it uses 'WaitOne' to avoid possible problems
which can occur on some machines (don't know why).
However I think that this will give you on a lot of places in the world very
much respect
MessageBox.Show("Anwendung wird bereits ausgeführt!")


Oh, sorry...

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

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

Similar topics

3
by: Moosebumps | last post by:
I'm wondering what kind of checking I can do on a python program before running it (besides reading over every line). I hate running a long python script, only to have it fail at the end because I...
13
by: Deepak Sarda | last post by:
Hello everyone. I have run into something which I believe is a bug or a shortcoming of the threading.Thread module. My program spawns 15 threads. For this I've creating a new class with...
22
by: Qopit | last post by:
Hi there, I'm pretty new to Python and am trying to figure out how to get "will this code compile?"-like code checking. To me this is a pretty basic language/environment requirement, especially...
0
by: Mike Meyer | last post by:
The recent thread on threads caused me to reread the formal definition of SCOOP, and I noticed something I hadn't really impressed me the first time around: it's using staticly checkable rules to...
30
by: Michael B Allen | last post by:
I have a general purpose library that has a lot of checks for bad input parameters like: void * linkedlist_get(struct linkedlist *l, unsigned int idx) { if (l == NULL) { errno = EINVAL;...
5
by: kd | last post by:
Hi All, If the name of a process is known, is it possible to check whether it is in execution? What I did was to fetch all the processes running on the system using Process.GetProcesses() and...
7
by: pradeep_TP | last post by:
hello all, I want to know how can I check whether a web site us running or not. I have used HttpWebRequest but when I give a web site address, It takes few number of seconds to throw exception...
7
by: HIK | last post by:
Click once can be set up to pole the setup url if there is a newer version or not. I have a project which can only be deployed using a setup project. How can I create the same feature in my setup...
125
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this...
3
by: John Wright | last post by:
I need to know how to check the state of a windows service. I need to determine if the windows service "Smart Card" is running. If it is not running, I need to start the service. Also it would...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.