是否有可能获得当前活动的应用程序的名称 [英] Is it possible to get the name of current active application

查看:98
本文介绍了是否有可能获得当前活动的应用程序的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户可以通过Alt + Tab键或单击其在任务栏图标切换活动的应用程序。是否有可能获得当前活动的应用程序的名称(或其他独特的特点)?

User can switch active application by Alt+Tab or by clicking on their icons in TaskBar. Is it possible to get the name (or other unique characteristic) of current active application?

我想编写一个程序,收集应用程序使用情况的统计数据。

I want to write a program which collects statistic of the applications usage.

推荐答案

在Windows API有一个名为函数<一个href="http://msdn.microsoft.com/en-us/library/ms633505%28VS.85%29.aspx?ppud=4">GetForegroundWindow().您将需要使用P / Invoke来调用到的Win32 API。在P / Invoke的wiki有更多信息中的C#用户。

The Windows API has a function called GetForegroundWindow(). You will need to use P/Invoke to call into the Win32 API. The P/Invoke wiki has more info for C# users.

请参阅<一href="http://www.csharphelp.com/2006/08/get-current-window-handle-and-caption-with-windows-api-in-c/">this页它获取当前应用程序的标题(名称)的一个例子。

See this page for an example which gets the caption (name) of the current application.

这篇关于是否有可能获得当前活动的应用程序的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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