2

Found the solution here: http://blogs.msdn.com/b/oldnewthing/archive/2007/10/08/5351207.aspx


I'm trying to go a list of running applications, i found on several forums this solution:

Process[] processes = Process.GetProcesses();
foreach (var proc in processes)
{
     if (!string.IsNullOrEmpty(proc.MainWindowTitle))
        Console.WriteLine(proc.MainWindowTitle);
}

exept this is not giving me the same list as when you press alt-tab. For example: firefox, explorer, and iexplore all return an empty/null MainWindowTitle. Is there another way to access this list? Maybe thru a windowsAPI?

I'm am using Windows 7 32bit

Thank you in advanced.

JSK
  • 61
  • 1
  • 8
  • http://www.eggheadcafe.com/tutorials/csharp/cb972d77-0892-4bf7-834d-c23b6dd5c03a/c--get-the-all-running-processes-and-applications.aspx it may help you – Kemal Can Kara Nov 29 '11 at 13:22
  • 1
    possible duplicate of [Enumerate windows like alt-tab does](http://stackoverflow.com/questions/210504/enumerate-windows-like-alt-tab-does) – Christian.K Nov 29 '11 at 13:45
  • Also see the [accepted answer](http://stackoverflow.com/a/210519/21567) which references a blog entry of Raymond Chen, that gives details. – Christian.K Nov 29 '11 at 13:46

2 Answers2

0

There are no hidden processes on Windows. Only processes you do not have (security) rights to see.

have a look at the below:

Retrieve a complete processes list using C#

Community
  • 1
  • 1
Massimiliano Peluso
  • 26,379
  • 6
  • 61
  • 70
0

Try this (taken from here), but I'm not sure it solves your problem:

static void Main(string[] args)
{
    GetProcesses();
    GetApplications();
    Console.Read();
}
public static void GetProcesses()
{
    StringBuilder sb = new StringBuilder();
    ManagementClass MgmtClass = new ManagementClass("Win32_Process");

    foreach (ManagementObject mo in MgmtClass.GetInstances())           
        Console.WriteLine("Name:" + mo["Name"] + "ID:" + mo["ProcessId"]);               

    Console.WriteLine();
}

public static void GetApplications()
{
    StringBuilder sb = new StringBuilder();
    foreach (Process p in Process.GetProcesses("."))
        try
        {
            if (p.MainWindowTitle.Length > 0)
            {
                Console.WriteLine("Window Title:" + p.MainWindowTitle.ToString());
                Console.WriteLine("Process Name:" + p.ProcessName.ToString());
                Console.WriteLine("Window Handle:" + p.MainWindowHandle.ToString());
                Console.WriteLine("Memory Allocation:" + p.PrivateMemorySize64.ToString());                     
            }
        }
        catch { }
}
Marco
  • 56,740
  • 14
  • 129
  • 152
  • Thank you, but it doesn't solve my problem. I am seeing all the processes but the getapplications function only gives me one running program (its own process). – JSK Nov 29 '11 at 14:02