Process Module Set C# with Example



Process Module Set C# with Example

 using System;
using System.Linq;
using System.Diagnostics;

namespace CSharpMultiThreading
{
    class MainMethodClass
    {
        static void Main()
        {
			EnumModsForPid(9912);
        }
    	
		static void EnumModsForPid(int pID)
		{
			Process theProc = null;
			
			try
			{
				theProc = Process.GetProcessById(pID);
			}
			catch(ArgumentException ex)
			{
				Console.WriteLine(ex.Message);
				return;
			}
			Console.WriteLine("Here are the loaded modules for: {0}", theProc.ProcessName);
			ProcessModuleCollection theMods = theProc.Modules;

			foreach(ProcessModule pm in theMods)
			{
				string info = string.Format("-> Module Name: {0}", pm.ModuleName);
				Console.WriteLine(info);
			}
		}
	}
}
 

0 Comment's

Comment Form

Submit Comment