You can not select more than 25 topics
Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System.Diagnostics;
- using System.Management;
- using System.Text;
-
- namespace Shadowsocks.Util.ProcessManagement
- {
- static class ThreadUtil
- {
-
- /*
- * See:
- * http://stackoverflow.com/questions/2633628/can-i-get-command-line-arguments-of-other-processes-from-net-c
- */
- public static string GetCommandLine(this Process process)
- {
- var commandLine = new StringBuilder(process.MainModule.FileName);
-
- commandLine.Append(" ");
- using (var searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id))
- {
- foreach (var @object in searcher.Get())
- {
- commandLine.Append(@object["CommandLine"]);
- commandLine.Append(" ");
- }
- }
-
- return commandLine.ToString();
- }
- }
- }
|