java 顶层提示_如何将应用程序连接到最顶层的窗口?

我的VB.NET应用程序用于监视当前在最顶层窗口中运行的应用程序 . 我使用计时器尝试了以下方法:

Declare Function GetActiveWindow Lib "user32" () As System.IntPtr

Declare Function GetForegroundWindow Lib "user32" () As System.IntPtr

Public Declare Auto Function GetWindowText Lib "user32" _

(ByVal hWnd As System.IntPtr, _

ByVal lpString As System.Text.StringBuilder, _

ByVal cch As Integer) As Integer

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Dim Caption As New System.Text.StringBuilder(256)

Dim hWnd As IntPtr = GetForegroundWindow()

GetWindowText(hWnd, Caption, Caption.Capacity)

'Caption now holds the title of the topmost window

End Sub

通过这个我可以看到,例如Outlook或Internet Explorer是最顶层的窗口,因为名称在Window的 Headers 栏中 . 但是,如果用户在Outlook中创建新邮件,则窗口 Headers 为“无 Headers 消息”,而不显示窗口中正在运行的应用程序的提示 .

如何获取连接到最顶层窗口的应用程序?p>

感谢帮助!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值