473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to find a particular program is running or not?

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
2 2946
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: NetMasker | last post by:
Using VB.NET 2003 I want to keep a program running and waiting for users' input without using a Form that loads at program execution. Can I do it using just one Module or what? Is this possible or...
2
by: Razor | last post by:
How can I call a sub and keep the main program running while it works?
8
by: Chris Thunell | last post by:
I have created a VB.net windows forms application. If I have the program running and then I mistakenly click on my desktop icon again, I get a second instance of the program running. Is there...
6
by: Cyril Vi?ville | last post by:
As it's written in the subject, i would like to know how can i find which program modified a file (last access, last changed). By example: Example.txt in a log directory I need to know which...
14
by: William LaMartin | last post by:
If I have a Windows application with no form--only a module that starts with sub main and which has a system timer, in the elapsed event of which I want to run some code, how can I keep this...
1
by: kunal30doshi | last post by:
hi, i want to find particular char. from entire char. field within given range. Ex Field x is 10 char field and it's value is YYYYNNNNYY. i want to know if n is exist in this field withing...
1
by: sai14 | last post by:
Hi all, i would like to know if it is possible find particular string in a text file using vc++? please do let me know how to write the syntax Thanks
3
by: cplusplusquestion | last post by:
# time ./a.out test.data the output: real 0m49.172s user 0m5.638s sys 0m4.850s Why real time and user time have big difference? I've tried to change a code: for example disable...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.