C#中如何获取其他进程的命令行参数 ( How to get other processes's command line argument )
From: jiangong.li_SW
To: dongpo.zhu_SW
Date Sent: 12/29/2012 10:42:37 AM
private static IEnumerable<string> GetCommandLines(string processName)
{
List<string> results = new List<string>();
string wmiQuery = string.Format("select CommandLine from Win32_Process where Name='{0}'", processName);
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmiQuery))
{
using (ManagementObjectCollection retObjectCollection = searcher.Get())
{
foreach (ManagementObject retObject in retObjectCollection)
{
results.Add((string)retObject["CommandLine"]);
}
}
}
return results;
}
static void Main(string[] args)
{
var result = GetCommandLines("msvsmon.exe");
Console.Read();
}
李建功 Li Jiangong
软件部 Software Dept.
上海联影医疗科技有限公司
Shanghai United Imaging Healthcare Co., Ltd.
上海市浦东新区海科路99号3号楼
上海市嘉定工业区兴贤路1180号B4幢
深圳市南山区蛇口沿山路43号创业壹号C栋
手机:13774373749
电子邮箱:jiangong.li@united-imaging.com
公司网址:http://www.united-imaging.com