Csharp/C Sharp by API/System.Diagnostics/ProcessModule

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

ProcessModule.ModuleName

<source lang="csharp">

using System; using System.Diagnostics; class MainClass {

 public static void EnumModsForPid(int pID)
 {
   Process theProc;
   try {
       theProc = Process.GetProcessById(pID);
     } catch {
     Console.WriteLine("-> Sorry...bad PID!");
     return;
   }
   
   Console.WriteLine("Here are the loaded modules for: {0}", theProc.ProcessName);
   try
   {
     ProcessModuleCollection theMods = theProc.Modules;
     foreach(ProcessModule pm in theMods)
     {
       string info = string.Format("-> Mod Name: {0}", pm.ModuleName);
       Console.WriteLine(info);
     }
   }
   catch{Console.WriteLine("No mods!");}
 }
 static void Main(string[] args)
 {
   int theProcID = 10001;
   EnumModsForPid(theProcID);
 }

}

 </source>