Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5 C#
Hi,
How can we get all the running applications name in an array using c#?
 
I can get all the processes but I want application names in Windows task manager-->Applications window.
 
Thanks in Advance.
Posted 20-May-11 1:51am
2000 P569
Edited 20-May-11 2:10am
v2
Comments
BobJanova at 20-May-11 8:23am
   
That appears to be a list of -windows-, not application names. Look at the Win32 API for a way to enumerate top level windows.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Since you want to know the Applications which are running instead of processes, here is one discussion:
http://bytes.com/topic/c-sharp/answers/487745-available-applications-taskmanager-not-processess-c[^]
  Permalink  
Comments
CS2011 at 20-May-11 12:21pm
   
Useful info
Tarun.K.S at 20-May-11 13:06pm
   
Thanks, it should work now. :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

Reflection is the best way to find out product name,company name version like information.

public static string ProductName
{
 get
 {
  AssemblyProductAttribute myProduct =
                                           (AssemblyProductAttribute)AssemblyProductAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),
                   typeof(AssemblyProductAttribute));
              return myProduct.Product;
  }
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

the simplest way i know is to use automation:
 
private void LoadApplicationNames()
{
    // the current desktop
    AutomationElement rootElement = AutomationElement.RootElement;
    var childs = AUW.Getchildrens(rootElement);
 
    foreach (AutomationElement elemnt in childs)
    {
        string name = elemnt.Current.Name;
        if (!string.IsNullOrWhiteSpace(name))
        {
            var listboxitem = new ListBoxItem();
            listboxitem.Content = name;
            // save the AutomationId in the tag
            listboxitem.Tag = elemnt.Current.AutomationId;
            listBox1.Items.Add(listboxitem);
        }
    }
 
 
/// <summary>
/// Retrieves all children under AutomationElement
/// </summary>
/// <param name="parent">The list element.</param>
/// <returns>all childrens </returns>
        public AutomationElementCollection Getchildrens(AutomationElement parent)
        {
            Condition findCondition = new PropertyCondition(AutomationElement.IsControlElementProperty, true);
            AutomationElementCollection childrens = parent.FindAll(TreeScope.Children, findCondition);
            return childrens;
        }
 
}
  Permalink  
Comments
soox at 4-Sep-12 13:23pm
   
what is AUW ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try This
 
IEnumerable<Process> processList =
    from p in Process.GetProcesses()
    orderby p.WorkingSet64 descending
    select p;
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try this
 
//To get Product name - not necessarily the same as the executeable
            string appName = Application.ProductName;
            MessageBox.Show(appName);
            //To find the name of the executable
            appName = Path.GetFileName(Application.ExecutablePath);
            MessageBox.Show(appName);
 
Hope this helps
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Process[] RunningProcess=Process.GetProcesses();
List<string> ProcessNames= new List<string>();
foreach(Process EachProcess in RunningProcess)
{
    ProcessNames.Add(EachProcess.ProcessName);
}</string></string>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hope this will help you.
 
String thismodulefilenamestr =
System.IO.Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 9

foreach (Process p in Process.GetProcesses())
            {
                string procFile;
                try
                {
                    procFile = p.Modules[0].FileName;
                }
                catch (Exception)
                {
                    procFile = "n/a";
                }
                Console.WriteLine(string.Format("Process {0}: {1}", p.ProcessName, procFile));
                
            }
            Console.ReadLine();
  Permalink  
v4
Comments
André Kraak at 21-Feb-12 2:54am
   
Edited solution:
Added pre tags
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 10

also u can try............
 
static void Main(string[] args)
            {
                  var myID = Process.GetCurrentProcess();
                  var query = string.Format("SELECT ParentProcessId FROM Win32_Process");// WHERE ProcessId = {0}", myID);
                  var search = new ManagementObjectSearcher("root\\CIMV2", query);
                  var results = search.Get().GetEnumerator();
                  if (!results.MoveNext())
                        throw new Exception("Huh?");
                  var queryObj = results.Current;
                  uint parentId = (uint)queryObj["ParentProcessId"];
                  var parent = Process.GetProcesses(); //.GetProcessById((int)parentId);
                  foreach(Process proc in parent){
                  Console.WriteLine("I was started by {0}", proc);}
                  Console.ReadLine();
            }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 11

also u want the application name that run in application tab of task manager in c#
foreach (Process p in Process.GetProcesses())
                  {
                        if (p.MainWindowTitle.Length > 0)
                        {
                              Console.WriteLine(p.MainWindowTitle.ToString());
                              Console.WriteLine(p.ProcessName.ToString());
                              Console.WriteLine(p.MainWindowHandle.ToString());
                              Console.WriteLine(p.PrivateMemorySize64.ToString());
                        }
                  }
                  Console.ReadLine();
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 13

Hi,
 
I recently used the following code to get the application name.
 
Check the code once.
 
public bool IsProcessOpen(string applicationName)
        {
            foreach (Process clsProcess in Process.GetProcesses())
            {
                
                if (clsProcess.ProcessName.Contains(applicationName))
                {
                    //if the process is found to be running then we
                    //return a true
                    return true;
                }
            }
            //otherwise we return a false
            return false;
        }
Thanks
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 12

Try it works
 
foreach (Process process in Process.GetProcesses())
{
string sWindow = process.MainWindowTitle; //returns window text appearing
//on apps form caption
}
 

//sandeep
  Permalink  
Comments
ProgramFOX at 26-Dec-12 6:29am
   
This is a question from 2011, why do you answer to it? The question is solved already.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 555
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 359
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 26 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100