Jump to content
  • Advertisement
Sign in to follow this  
one mind

Can a program detect if another program is running?

This topic is 4689 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am trying to find a way that my c# winform program can detect if another peice of software is running.I want my program to display when a certain program is active and to hide when its not. Any ideas would be great. Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
Yes, indeed it can. I think I did it by looking at the running processes and seaching for the one that you need.

I'll try to find the source for that..
[edit]
What you want to look into is
System.Diagnostics.Process 

What I did for my app (I just needed to kill another process when my app was started..it happened to be an updator..not sure if this is the proper way..but it works well

foreach (Process Pr in Process.GetProcesses()) //loop through all running processs
if (Pr.ProcessName.Contains("Schools eGuide")) //if the name contains Schools e Guide
Pr.Kill(); //end the process (exit the Schools eGuide program)


hope that helps ya
[/edit]
ArchG

Share this post


Link to post
Share on other sites
Thanks ArchG

That works great :)

My problem now is, putting it in my program so it runs every time a new window becomes active. Eg

When my program starts, it is minimized and runs in the background. I want it to check the process names each time another program is made active. Like, for example, if i had 3 notepads open, one will be active and the other 2 will be behind and unactive. If i then click one of the unactive notepads, i want my program to then check that processes name.

It seems that, when my program is minimized, it stops running all code, for example, i have a mouse move event and it works when my program is selected, but doesn't work when my program is minimized.

Is it possible for my program to watch for changes when it is in the background? Or will i need to make a windows service or something?

Thanks again

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!