Retrieving Process Description Information

This is the only way I could see to do it. I tried Process and Win32_Process, but no go.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
using System.Diagnostics;

namespace Management
{
    class Program
    {
        static void Main(string[] args)
        {
            var ps = Process.GetProcesses();

            foreach (var p in ps)
            {
                try
                {
                    var desc = FileVersionInfo.GetVersionInfo(p.MainModule.FileName);
                    Console.WriteLine(desc.FileDescription);
                }
                catch
                {
                    Console.WriteLine("Access Denied");
                }
            }

            Console.ReadLine();
        }
    }
}

You just have to go a bit further down the properties. Suppose you have an instance of notepad running.

Process[] proc = Process.GetProcessesByName("notepad");
Console.WriteLine("Process version- " + proc[0].MainModule.FileVersionInfo.FileVersion);
Console.WriteLine("Process description- " + proc[0].MainModule.FileVersionInfo.FileDescription);

There you go !


What you see in Task Manager is actually the Description field of the executable image.

You can use the GetFileVersionInfo() and VerQueryValue() WinAPI calls to access various version informations, e.g. CompanyName or FileDescription.

For .Net way, use the FileDescription member of FileVersionInfo, instantiated with the executable name got via Process.MainModule.FileName.

Another way would be through Assembly. Load the Assembly from the executable image, then query the AssemblyDescriptionAttribute custom attribute.

Tags:

C#

.Net