从标题栏捕获当前正在运行的应用程序的名称. [英] capturing name of currently running application from titlebar.

查看:74
本文介绍了从标题栏捕获当前正在运行的应用程序的名称.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hiii
在我的应用程序中,我想从标题栏中捕获每个当前正在运行的应用程序的名称,因为当我打开新应用程序时,我想获取标题栏中显示的新的当前正在运行的应用程序的名称.

hiii
in my application i want to capture the name of each currently running application from the titlebar,as i open new application then i want to get the name of new currently running application shown in titlebar.

推荐答案

您应该记住,使用文字作为标题栏不能可靠地用于应用程序标识.

您应该使用静态方法System.Diagnostics.Process.GetProcesses列出系统上运行的所有进程.该方法返回的每个进程都由类System.Diagnostics.Process的实例表示.您可以使用属性System.Diagnostics.Process.MainWindowTitle -这就是您要问的问题.请确保将对此属性的调用放在try-catch块下,因为当无法定义此值(关闭的进程,不使用主窗口的进程等)时,此调用将引发异常.

请查看Process类的其他属性以及System.Diagnostics.Process.MainModule的属性.此属性表示入口程序集的主要模块,即人们所说的可执行文件"(在.NET中不是严格的概念,这就是我上面提到的内容).

—SA
You should remember that using the text is the title bar can not be reliably used for application identification.

You should list all the processes running on the system, using the static method System.Diagnostics.Process.GetProcesses. Each process returned by this method is represented by the instance of the class System.Diagnostics.Process. You can use the property System.Diagnostics.Process.MainWindowTitle — this is what are you asking about. Make sure you put the call to this property under try-catch block as this call will throw exception when this value cannot be defined (closed processes, processes not using main window, etc.).

Please see other properties of the Process class and also the properties of System.Diagnostics.Process.MainModule. This property represent main module of the entry assembly, what people refer to as "executable file" (which not a strict notion in .NET, it is what I mentioned above).

—SA


这篇关于从标题栏捕获当前正在运行的应用程序的名称.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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