您的位置:首页 > 编程语言 > C#

C#中如何获取其他进程的命令行参数 ( How to get other processes's command line argument )

2013-07-10 15:42 627 查看
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(); } 任务管理器中实际的参数如下, 该程序或得到3个item的string。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐