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。
相关文章推荐
- C#中如何获取其他进程的命令行参数 ( How to get other processes's command line argument )
- C#中如何获取其他进程的命令行参数 ( How to get other processes's command line argument )
- How to get the file's icon using C++ - 用C++如何获取文件的图标
- idhttp1.get('www.google.cn')时报 Invalid argument to date encode错误,如何解决。
- How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
- C# 使用 Environment.GetCommandLineArgs 方法 制作*.exe和参数 供其他程序调用
- 在初始对话框中利用函数GetCommandLineW获取MFC程序的命令行参数
- How to get MetaData on client side in WCF?如何在客户端获取WCF service的元数据
- How to get the size of file in C++ - 在C++中如何获取文件的大小
- How To Use Function 'F4_FILENAME' and 'KD_GET_FILENAME_ON_F4'
- How to use 'SetItemData()' and 'GetItemData()'?
- GetCommandLine 获取当前进程的命令行字符串 对字符串进行分割
- All-In-One Code Framework(AIO): 如何使用C#编写进程外的COM组件 (How to write an out-of-proc COM server in C#)
- How to get random number within a range using C++ - 如何用C++获取一定范围内的随机数
- I don't know how to get a real life
- How to get local machine date format.如何获取本机时间格式
- How to use 'SetItemData()' and 'GetItemData()'?
- Java Tip 26: How to improve Java's I/O performance-如何提高java I/O性能
- How to get the content of the 'identity' section in web.config
- How to use 'cp' command to exclude a specific directory?