// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Diagnostics; namespace E { public class Program { private static bool DllLoaded(string dllName) { foreach(Process myProcess in Process.GetProcesses()) { try { foreach(ProcessModule myProcessModule in myProcess.Modules) { //Console.WriteLine(myProcess.MainModule.ModuleName + " " + myProcessModule.ModuleName); if(myProcessModule.ModuleName.ToLower() == dllName.ToLower()) { return true; } } } catch { // Security - some module we can not query. } } return false; } public static void Main(string[] args) { DateTime dt1 = DateTime.Now; Console.WriteLine(DllLoaded("E13.exe")); Console.WriteLine(DllLoaded("System.Data.dll")); Console.WriteLine(DllLoaded("Foobar.dll")); DateTime dt2 = DateTime.Now; Console.WriteLine((dt2 - dt1).TotalSeconds/3); } } }