在 VB.NET 中获取进程的名称 [英] Getting the name of a process in VB.NET

查看:61
本文介绍了在 VB.NET 中获取进程的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找如何找到使用 System.Diagnostics.Process.GetProcesses 获取的进程对象的名称(例如,对于进程 firefox, 'Firefox') ,并没有找到任何东西.我试过使用 MainWindowTitle,但它没有返回Firefox",而是返回当前选项卡的名称,因为 Firefox 将其命名为窗口.有什么办法可以找到进程的实际显示名称吗?

I've been looking around for how to find the name of a process object gotten using System.Diagnostics.Process.GetProcesses (for instance, for the process firefox, 'Firefox') , and haven't been able to find anything. I've tried using MainWindowTitle, but instead of returning 'Firefox' it returns the name of the current tab, as that's what Firefox names it's window. Is there any way to find the actual display name of a process?

推荐答案

For Each p As Process In Process.GetProcesses()
    Debug.WriteLine(p.ProcessName)
Next

这可能有效,但未经测试.https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.processname

This might work, but is untested. https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.processname

这篇关于在 VB.NET 中获取进程的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆