473,486 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to list running programs in C#?

28 New Member
I want to be able to set a string array to all the programs running (only the ones visible on the taskbar). Is this possible in C#? Thanks in Advance :D
Dec 18 '10 #1
8 3536
bentleyw
32 New Member
Something like this may do it for you...

Expand|Select|Wrap|Line Numbers
  1.             Process[] processRunning = Process.GetProcesses();
  2.             StringBuilder sbProcesses = new StringBuilder();
  3.             foreach (Process currProcess in processRunning)
  4.             {
  5.                 if (currProcess.MainWindowHandle.ToInt32() > 0)
  6.                     sbProcesses.Append(currProcess.ProcessName + "\n");
  7.             }
  8.             MessageBox.Show(sbProcesses.ToString());
Dec 18 '10 #2
Josh Argent
28 New Member
I get an error for 'processRunning' saying it does not exist in the current context :(. Thanks
Dec 18 '10 #3
bentleyw
32 New Member
Not sure if it alerts you on an edit, but I've added the line of code to make it work. Good luck.
Dec 18 '10 #4
Josh Argent
28 New Member
Thanks bentleyw, works fine now :)
Dec 18 '10 #5
Josh Argent
28 New Member
emm bentleyw, do you know how I can set a combobox to that array? I've tried comboBox1.DataSource = sbProcesses; but that doesn't work :( Do you know how I can do this? Thanks :D
Dec 18 '10 #6
bentleyw
32 New Member
Sure. Assuming that the ComboBox is named "cmbProcesses", you could use a list like this:
Expand|Select|Wrap|Line Numbers
  1.             Process[] processRunning = Process.GetProcesses();
  2.             List<string> processList = new List<string>();
  3.             foreach (Process currProcess in processRunning)
  4.             {
  5.                 if (currProcess.MainWindowHandle.ToInt32() > 0)
  6.                     processList.Add(currProcess.ProcessName);
  7.             }
  8.             cmbProcesses.DataSource = processList;
Or you could fill a DataTable (for example, if you want to carry other info along with each process) and set the DisplayMember property of the ComboBox to the column name from the table.
Dec 18 '10 #7
Josh Argent
28 New Member
Thanks for all your help. I can now finish my application :D
Dec 18 '10 #8
bentleyw
32 New Member
No problem. Glad to help. :)
Dec 18 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
976
by: M.N.A.Smadi | last post by:
hi; in general: how can i pass a string containing a concatenated sequcne of command line arguments to a unix system CLI? my specific problem: i have an executable that is called xyz (written...
1
1526
by: Sathyaish | last post by:
Scenario =========== (1) You write a program using some programming language, say, C#. (2) You make an assembly out of the program by compiling it. It is a single module assembly. (3) You...
1
6009
by: Antoine | last post by:
Hello, Does anybody know a way to retreive the running timers (their ids) in a html page? I cannot find something in the html dom at first sight. Is there collection of timers available (like...
1
1782
by: Al Sav | last post by:
Hello, I am trying to find the file location and file names of all the processes that I see in windows task manager. How can I list all the exes that are running currently? Thanks in advance,...
1
2142
by: Dan Nilsson | last post by:
I am developing a command line program which needs to get information from command line switches every now and then. So instead of starting a new instance when the program is executed, it will pass...
3
1400
by: Janos Makadi | last post by:
Hi, I have a very interesting problem. I wrote a little code which linked against an externel library. I have the debug, and the release version of the ext. lib. One library function opens a...
0
270
by: Joachim | last post by:
Hello everybody, I'm here again having another question! In my sidebar-application I want to mimic the functionality of the NotifyIcon-class. My idea is to implement a NotifyArea-class that is...
9
1830
by: Andrzej | last post by:
Greetings. Is there any project of universal environment for running programs written in C++ ? For example a programmer compiles program using compilator and linker that produces universal...
1
1172
by: danasegarane | last post by:
Hi all, I am using this code this code to list the all the running proces handle for each p as process in Process.GetProcesses listbox1.items.add(p.mainwindowtitle) next The...
2
1200
by: samslists | last post by:
So I have a python program that runs a bunch of other programs....it then loops forever, occasionally executing other programs. To run each of these programs my python code executes:...
0
7094
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
6964
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
7173
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...
0
5427
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4863
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.