How to find a particular program is running or not?

D

DBC User

I have a program which ccan be called multiple times. Each time, it
will open a window and the windows title has unique name. I do not
have any control over this program. I want to know is there a way to
find out which are all the windows open and also how to identify the
windows title?

I want to check if a particular window is opened with a known title. I
know the title. I tried using Process and ProcessByName and it is not
working since the launching program store the title anywhere in the
process.

When I looked at the task manager, under application I can see the
name I am looking for. Is there a way I can get to this information?

Thanks.
 
J

justin creasy

I have a program which ccan be called multiple times. Each time, it
will open a window and the windows title has unique name. I do not
have any control over this program. I want to know is there a way to
find out which are all the windows open and also how to identify the
windows title?

I want to check if a particular window is opened with a known title. I
know the title. I tried using Process and ProcessByName and it is not
working since the launching program store the title anywhere in the
process.

When I looked at the task manager, under application I can see the
name I am looking for. Is there a way I can get to this information?

Thanks.

If you want to get a list of Processes that have a window try this
line of code.

ArrayList programlist = new ArrayList();
Process[] procList = Process.GetProcesses(userName);

for (int i = 0; i < procList.Length; i++)
{
if (procList.MainWindowHandle != IntPtr.Zero)
{
programlist.Add(procList.ProcessName + "\t" +
procList.MainWindowTitle);
}
}

This assumes you know the name of the logged in user (It will only get
the applications launched by the specified user, but that should be
fine for your purposes). If you don't you can obtain it through the
System.Environment class I believe.

When this code is done you will have the list of applications shown in
the Windows Task Manager. You can play around with the different
attributes like ProcessName and MainWindowTitle to find the
information you're looking for. Hope this helps. If you have any
problems with it just post back here. Good luck.

~ Justin Creasy
www.immergetech.com
www.immergecomm.com
 
D

DBC User

I have a program which ccan be called multiple times. Each time, it
will open a window and the windows title has unique name. I do not
have any control over this program. I want to know is there a way to
find out which are all the windows open and also how to identify the
windows title?
I want to check if a particular window is opened with a known title. I
know the title. I tried using Process and ProcessByName and it is not
working since the launching program store the title anywhere in the
process.
When I looked at the task manager, under application I can see the
name I am looking for. Is there a way I can get to this information?

If you want to get a list of Processes that have a window try this
line of code.

ArrayList programlist = new ArrayList();
Process[] procList = Process.GetProcesses(userName);

for (int i = 0; i < procList.Length; i++)
{
if (procList.MainWindowHandle != IntPtr.Zero)
{
programlist.Add(procList.ProcessName + "\t" +
procList.MainWindowTitle);
}

}

This assumes you know the name of the logged in user (It will only get
the applications launched by the specified user, but that should be
fine for your purposes). If you don't you can obtain it through the
System.Environment class I believe.

When this code is done you will have the list of applications shown in
the Windows Task Manager. You can play around with the different
attributes like ProcessName and MainWindowTitle to find the
information you're looking for. Hope this helps. If you have any
problems with it just post back here. Good luck.

~ Justin Creasy
www.immergetech.com
www.immergecomm.com


Thanks, it is what I was looking for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top