By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,949 Members | 2,043 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,949 IT Pros & Developers. It's quick & easy.

How to find a particular program is running or not?

P: n/a
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.

Mar 9 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Mar 9, 10:52 am, "DBC User" <dbcu...@gmail.comwrote:
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[i].MainWindowHandle != IntPtr.Zero)
{
programlist.Add(procList[i].ProcessName + "\t" +
procList[i].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

Mar 9 '07 #2

P: n/a
On Mar 9, 4:52 pm, "justin creasy" <justin.cre...@gmail.comwrote:
On Mar 9, 10:52 am, "DBC User" <dbcu...@gmail.comwrote:
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[i].MainWindowHandle != IntPtr.Zero)
{
programlist.Add(procList[i].ProcessName + "\t" +
procList[i].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.

Mar 14 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.