All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
.net获取w3wp进程对应的应用程序池_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/23 2:48:22 Browse times: 330 Comment times: 0

.net获取w3wp进程对应的应用程序池_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

.net获取w3wp进程对应的应用程序池_[Asp.Net教程]

C#.net

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

namespace TextConvertor
{
/**////


/// W3wp 的摘要说明。
///

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();
}
}
}





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.