1.获取进程的命令行信息
using System.Management;
/// <summary>
/// 获取进程的命令行信息
/// </summary>
/// <param name=\”id\”></param>
/// <returns></returns>
string GetCommandLineArgsCore(int id)
{
using (var searcher = new ManagementObjectSearcher(
\”SELECT CommandLine FROM Win32_Process WHERE ProcessId = \” + id))
using (var objects = searcher.Get())
{
var @object = objects.Cast<ManagementBaseObject>().SingleOrDefault();
return @object?[\”CommandLine\”]?.ToString() ?? \”\”;
}
}
2.获取进程文件路径
process.MainModule.FileName