473,406 Members | 2,404 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,406 software developers and data experts.

Check if instance of program is already running

oHi,

I want to check for a Windows form program if an instance of the prgram is
already running: if yes the program's window should be activated and no
second program instance should be started.

How can I perform this task in VB.Net?

Thanks in advance.
--
Best regards

Henry
Nov 21 '05 #1
3 2934
"Henry" <he********@nospam.nospam> schrieb:
I want to check for a Windows form program if an instance of the prgram is
already running: if yes the program's window should be activated and no
second program instance should be started.


Detecting another instance of the application:

<URL:http://www.yoda.arachsys.com/csharp/faq/#one.application.instance>

Bringing a window into the foreground (requires the window's handle, which
can be obtained by getting the process' 'Process' object and getting its
'MainWindowHandle' property value):

<URL:http://groups.google.de/groups?selm=%23gCaV7yaEHA.996%40TK2MSFTNGP12.phx.g bl>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
Henry,

When you are sure that your program name is a real unique name than this one
is very simple.
\\\
Private mut As New Threading.Mutex(True, "myProgram", mutCreated)
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not mutCreated Then Me.Close()
'etc
End Sub
//
I hope this helps?

Cor
Nov 21 '05 #3
Thanks Cor and Herfried!

That is exactly what I needed and it works quite fine.

Best regards

Henry

"Herfried K. Wagner [MVP]" wrote:
"Henry" <he********@nospam.nospam> schrieb:
I want to check for a Windows form program if an instance of the prgram is
already running: if yes the program's window should be activated and no
second program instance should be started.


Detecting another instance of the application:

<URL:http://www.yoda.arachsys.com/csharp/faq/#one.application.instance>

Bringing a window into the foreground (requires the window's handle, which
can be obtained by getting the process' 'Process' object and getting its
'MainWindowHandle' property value):

<URL:http://groups.google.de/groups?selm=%23gCaV7yaEHA.996%40TK2MSFTNGP12.phx.g bl>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4

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

Similar topics

2
by: Amrik Singh | last post by:
HI folks can anyone help a newbie here. I would like to know how I can check if my software is already running. So that if the user click s on the shortcut to start the progam again it maximises...
3
by: Fabio Pliger | last post by:
Hi, is it possibile, in python, to check for an already running instance of an application? My problem is that, if my program i running and the user relaunch it, i don't want to open a new...
6
by: Pierre-Yves | last post by:
Hello, I would like to prevent my perl program to be executed several times simultaneously (if the program is already running, I would like to display a message like "another instance of this...
4
by: Nick Sinclair | last post by:
Hi all, I'm new to C. I have successfully written a small C program that acts as a "wrapper" around cgi scripts. These scripts perform admin tasks such as backing up etc. Obviously, The need...
4
by: TM | last post by:
Is there any way to check if another instance of my program is running if a user executes it ? I would like to warn the user if the program is already running to prevent multiple instances. ...
0
by: ricky | last post by:
I found the code below on how to check for a previous instance of an app, but I don't think this will work for a network executeable. So, how do you check to see if there is multiple instances of...
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....
1
by: keri | last post by:
Hi, I use the below for the user to view their outlook calendar Sub DisplayInbox() Dim myolApp As Outlook.Application Dim myNameSpace As Outlook.NameSpace Dim myFolder As Outlook.MAPIFolder...
9
by: fniles | last post by:
I am using VB.NET 2005. To check if the same program already run or not, I can use the following If Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length MsgBox("Another...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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.