下面的代码未列出w3wp进程,winforms应用程序进程! 如何为w3wp进程标识应用程序池。这种方法正确吗?
代码
public static List<String> GetCLRManagedProcesses()
{
var managedProcesses = new List<Process>();
foreach (var process in Process.GetProcesses())
{
try
{
if (process != null && !process.HasExited)
{
for (int i = 0; (i < process.Modules.Count); i++)
{
try
{
var moduleName = process.Modules[i].ModuleName.ToLowerInvariant();
if (FrameworkLibraries().Contains(moduleName))
{
managedProcesses.Add(process);
}
else
{
// winforms, w3wp, all are entering here
}
}
catch (Exception e){ }
}
}
}
catch (Exception ex)
{
}
}
return managedProcesses
.Select(x => x.ProcessName)
.ToList();
}
private static IEnumerable<String> FrameworkLibraries()
{
return new[] { "mscoree.dll", "mscoreei.dll", "mscorwks.dll" };
}
任何帮助表示赞赏