如何从进程获取"project names"列表(不是进程名称或窗口标题)



我正在寻找一种方法来列出每个进程的应用程序名称。当你在visualstudio中制作项目时,它们就像项目名称一样。

我不想找的:

  1. 窗口标题
Process[] processes = Process.GetProcesses();
foreach (Process p in processes)
{
if (!String.IsNullOrEmpty(p.MainWindowTitle))
{
Console.WriteLine(p.MainWindowTitle);
}
}
  1. 进程名称
Process[] processes = Process.GetProcesses();
foreach (Process p in processes)
{
Console.WriteLine(p.ProcessName);
}

我在找什么:

任务管理器列表中的条目:

任务管理器列表

当p.MainModule抛出一些进程(查看它(时,

你需要的可以这样实现:

Process p = Process.GetProcessesByName("winword")[0];
string fileName = p.MainModule.FileName;
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(fileName);
// Writes "Microsoft Word"
Console.Write(myFileVersionInfo.FileDescription);

编辑1:

如果在64位环境中以32位运行,则p.MainModule似乎不可访问。

当编译到x64时,我的系统上与我的用户一起运行的所有进程都可以显示。对于其他项目,可能需要标高。

Failed: svchost, Reason: Access is denied
Succeeded: chrome = Google Chrome
Failed: sqlservr, Reason: Access is denied
Succeeded: SCNotification = SCNotification
Succeeded: VirtualMIDISynth = CoolSoft VirtualMIDISynth
Failed: NisSrv, Reason: Access is denied
Failed: TabTip32, Reason: Access is denied
Failed: RegSrvc, Reason: Access is denied
Failed: dwm, Reason: Access is denied
Failed: LMS, Reason: Access is denied
Failed: svchost, Reason: Access is denied
Succeeded: chrome = Google Chrome
Failed: EvtEng, Reason: Access is denied
Succeeded: OmniSharp = OmniSharp
Failed: taskhost, Reason: Access is denied
Failed: svchost, Reason: Access is denied
Succeeded: Code = Visual Studio Code
Succeeded: devenv = Microsoft Visual Studio 2013
Succeeded: ChsIME = Microsoft IME
Failed: SppExtComObj, Reason: Access is denied
Failed: svchost, Reason: Access is denied
Failed: WmiPrvSE, Reason: Access is denied
Succeeded: Code = Visual Studio Code
Failed: isa, Reason: Access is denied
Succeeded: conhost = Console Window Host

相关内容

  • 没有找到相关文章

最新更新