Obtain no. of instances of an application from within the same app

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Is there a clever way to get the number of instances started of an
application within the same application. Is it possible to implement an event
handler to key on the change in numbers of running application of same type.
I saw this implemented in c++ with a static integer in the main section...

regards
Jesper.
 
Hi Jesper,
you could use the System.Diagnostics.Process class and call
GetProcessesByName passing in the name of your process. This returns an
array ofpprocess informations, you could just count the number of items in
the list and thsis will tell you how many instances of your app are currently
running.

Hope that helps
Mark R Dawson
http://www.markdawson.org
 
You can use Process.GetProcessByName and count the number of processes it
returns.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Back
Top