自从用了ASP
NET
以后
这个问题被渐渐关注起来
目前的方法就是调用iisapp
vbs获取
今天准备在我的文本转换工具里集成这个功能于是用C#实现了一下
using System;
using SystemText;
using SystemTextRegularExpressions;
using SystemDiagnostics;
using SystemManagement;
using SystemWindowsForms;
namespace TextConvertor
{
/**//// <summary>
/// Wwp 的摘要说明
/// </summary>
public class Wwp
{
private Wwp(){}
public static string GetAllWwp(string input)
{
ObjectQuery oQuery = new ObjectQuery(select * from Win_Process where Name=wwpexe);
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oQuery);
ManagementObjectCollection oReturnCollection = oSearcherGet();
string pid;
string cmdLine;
StringBuilder sb = new StringBuilder() ;
foreach(ManagementObject oReturn in oReturnCollection)
{
pid = oReturnGetPropertyValue(ProcessId)ToString();
cmdLine = (string)oReturnGetPropertyValue(CommandLine);
string pattern = ap \(*)\ ;
Regex regex = new Regex(pattern RegexOptionsIgnoreCase) ;
Match match = regexMatch(cmdLine) ;
string appPoolName = matchGroups[]ToString() ;
sbAppendFormat(WWPexe PID: {} AppPoolId:{}\r\n pid appPoolName );
}
return sbToString();
}
}
}
实现的原理和VBScript简直一模一样