asp学习网: 首页 >> asp.net >> .net获取w3wp进程对应的应用程序池

.net获取w3wp进程对应的应用程序池

C#.net

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Management;
using System.Windows.Forms;

namespace TextConvertor
{
/**//// <summary>
/// W3wp 的摘要说明。
/// </summary>
public class W3wp
{
private W3wp(){}
public static string GetAllW3wp(string input)
{
ObjectQuery oQuery = new ObjectQuery("select * from Win32_Process where Name='w3wp.exe'");
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oQuery);
ManagementObjectCollection oreturnCollection = oSearcher.Get();

string pid;
string cmdLine;
StringBuilder sb = new StringBuilder() ;
foreach(ManagementObject oreturn in oreturnCollection)
{
pid = oreturn.GetPropertyValue("ProcessId").ToString();
cmdLine = (string)oReturn.GetPropertyValue("CommandLine");

string pattern = "-ap \"(.*)\"" ;
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase) ;
Match match = regex.Match(cmdLine) ;
string appPoolName = match.Groups[1].ToString() ;
sb.AppendFormat("W3WP.exe PID: {0} AppPoolId:{1}\r\n", pid, appPoolName );
}

return sb.ToString();
}
}
}

from:asp学习网/title:.net获取w3wp进程对应的应用程序池/ time:2007-5-16 11:38:14

本文主题应用程序池

IIS远程回收应用程序池

远程回收应用程序池

如何监控应用程序池的回收操作

asp教程 ©2006-2007 aspxuexi.com | 关于站点 | 版权隐私 | 站内搜索
复制或者翻版 请于夜间进行