Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to check multiple instances of an application..?

27 views
Skip to first unread message

kiran

unread,
Oct 3, 2005, 4:47:34 AM10/3/05
to
How can I check whether a application is laready running in the current
system...?

I want to check when the application is in "hidden" state. first instance
window style is "Hide" . When ever user trying to open a second or new
instance .it should detect the first instance automatically and first
instance should be activate and show to the user.( it can be any state
normal, minimize or maximize )

Regards
kiran


Vitaly Zayko

unread,
Oct 3, 2005, 5:05:37 AM10/3/05
to
Enum processes using System.Diagnostics.Process.GetProcessByName
see more in MSDN
Vit

Nicholas Paldino [.NET/C# MVP]

unread,
Oct 3, 2005, 1:20:08 PM10/3/05
to
kiran,

Juval Lowy created a neat little utility class which handles this. You
can download it from (watch for line wrap):

http://www.idesign.net/idesign/uploads/Singleton.zip

Basically, it uses a mutex to see if another app instance is open. If
it is, it uses remoting to send a message to that application, and show it.

This functionality is available in .NET as well. In .NET 2.0, you can
use the WindowsApplicationBase class in the
Microsoft.VisualBasic.ApplicationServices namespace to handle this
functionality for you. There is a question in the ".NET Matters" section of
the September issue of MSDN magazine that shows how to do this. You can
find it online at (watch for line wrap):

http://msdn.microsoft.com/msdnmag/issues/05/09/NETMatters/

Specifically, it is the second question.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"kiran" <vemul...@gmail.com> wrote in message
news:%23otEoa$xFHA...@TK2MSFTNGP10.phx.gbl...

Nicholas Paldino [.NET/C# MVP]

unread,
Oct 3, 2005, 1:23:13 PM10/3/05
to
This is actually a VERY bad idea. Enumerating through all of the
available processes can be quite intensive, and there are better ways to do
it.

Check my response for some of those ways.


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Vitaly Zayko" <vitaly_at_zayko_dot_net> wrote in message
news:ORziLm$xFHA...@TK2MSFTNGP10.phx.gbl...

0 new messages