Click here to Skip to main content
16,012,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sir,

According to my project need, I have to get a list of running Applications in Windows using C#.Net. I am able to get list of running processes using Process class in .Net.

Example:
C#
foreach (Process pr in Process.GetProcesses())
            {
                try
                {
                    Console.WriteLine(pr.ProcessName);
                }
                catch { }
            }

But this would result 'Visual Studio' as devenv or 'Microsoft Word' as winword. But I need to get the Application names, like Visual Studio , Microsoft Word , Firefox , Microsoft Excel and so on... Please help me on this requirement.
Thanks in advance!
Posted
Comments
BillWoodruff 26-Sep-11 6:35am    
You can use the 'MainWindowTitle' property of each Process to get some more information, but what you get is just the Window title which may, or may not, include Application Name information. Since this does not really answer your question, I include this as a comment, not an answer.

You can get the file description information via the following code :
C#
// first process
var p = Process.GetProcesses()[0]; 
string longname = FileVersionInfo.GetVersionInfo(p.MainModule.FileName).FileDescription;
 
Share this answer
 
v3
Comments
OriginalGriff 26-Sep-11 6:48am    
Good one! Just remember to check for null references...+5
BillWoodruff 26-Sep-11 6:59am    
+5.

Note: on my 64bit Win 7 machine using this technique will crash every time the VS Studio 2010 project tries to get access the 'MainModule' of a 64 bit process: the error message is: "A 32 bit processes cannot access modules of a 64 bit process"

And, note: you will find that some applications put up many windows, so you will get 'duplicates.'
Mehdi Gholam 26-Sep-11 7:03am    
HeHe! user discretion is advised!
Unfortunately, Processes are not the same as Applications: AFAIK you cannot get the original EXE name (it may not even be an exe) Certainly, all Process.StartInfo objects retrieved from GetProcesses has an empty FileName property.
 
Share this answer
 
Comments
Mehdi Gholam 26-Sep-11 6:40am    
It is possible see my code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900