473,378 Members | 1,162 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.

check if a apllication is already running?

jam
Dear all

Process [] checkpro = Process.GetProcessesByName("abc");
Console.WriteLine(checkpro [0]);

correct ma?? how should i do??

jam
Nov 16 '05 #1
4 28644
Hi Jam,

// get the name of our process

string proc=Process.GetCurrentProcess().ProcessName;

// get the list of all processes by that name

Process[] processes=Process.GetProcessesByName(proc);

// if there is more than one process...

if (processes.Length > 1)

{

MessageBox.Show("Application is already running");

return;

} else

Application.Run(new Form1());

Nirosh.

"jam" <hk***@hotmail.com> wrote in message
news:OU*************@TK2MSFTNGP11.phx.gbl...
Dear all

Process [] checkpro = Process.GetProcessesByName("abc");
Console.WriteLine(checkpro [0]);

correct ma?? how should i do??

jam

Nov 16 '05 #2
jam
Thx a lot!~!!!
"Champika Nirosh" <te**@test.lk> ¦b¶l¥ó
news:eN**************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g...
Hi Jam,

// get the name of our process

string proc=Process.GetCurrentProcess().ProcessName;

// get the list of all processes by that name

Process[] processes=Process.GetProcessesByName(proc);

// if there is more than one process...

if (processes.Length > 1)

{

MessageBox.Show("Application is already running");

return;

} else

Application.Run(new Form1());

Nirosh.

"jam" <hk***@hotmail.com> wrote in message
news:OU*************@TK2MSFTNGP11.phx.gbl...
Dear all

Process [] checkpro = Process.GetProcessesByName("abc");
Console.WriteLine(checkpro [0]);

correct ma?? how should i do??

jam


Nov 16 '05 #3
On Thu, 9 Dec 2004 11:47:08 +0600, Champika Nirosh wrote:
Hi Jam,

// get the name of our process

string proc=Process.GetCurrentProcess().ProcessName;

// get the list of all processes by that name

Process[] processes=Process.GetProcessesByName(proc);

// if there is more than one process...

if (processes.Length > 1)

{

MessageBox.Show("Application is already running");

return;

} else

Application.Run(new Form1());


I think that using Mutex will be much more appropriate here (at least in
order to prevent your application being started twice).

Michal Dabrowski
Nov 16 '05 #4
jam <hk***@hotmail.com> wrote:
Process [] checkpro = Process.GetProcessesByName("abc");
Console.WriteLine(checkpro [0]);

correct ma?? how should i do??


If you're trying to check for your own process, I'd suggest using a
mutex. See
http://www.pobox.com/~skeet/csharp/f...ation.instance

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5

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: Michael Passalacqua | last post by:
In VB.NET, how do you check to see if an instance of your application is already running? Michael Passalacqua Portland Community College CIS Faculty *** Sent via Developersdex...
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. ...
14
by: Alex K. | last post by:
Hi all I'd like to avoid starting the same c# application twice on the same computer. How do I check if it is already running? Thank you
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...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.