关键词搜索

源码搜索 ×
×

如何捕捉窗口句柄

发布2006-03-08浏览1701次

详情内容

需要VB API函数:
FindWindow                              ←寻找窗口列表中第一个符合指定条件的顶级窗口
GetWindowThreadProcessId       ←获取与指定窗口关联在一起的一个进程和线程标识符


相关API声明:
FindWindow

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

GetWindowThreadProcessId

Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long)
As Long

需要的控件:Label、Timer

   自定义函数:
Dim hwnd As Long

  源代码:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long)As Long
Private Sub Timer1_Timer()
Dim hwnd As Long' 储存 FindWindow 函数返回的句柄
hwnd = FindWindow(vbNullString, "Windows Media Player")' 取得进程标识符
'只要把Windows Media Player换成别的程序名称就可了!
If hwnd = 0 Then
Label1.Caption = "未运行"
Else
Label1.Caption = "已运行"
End If
End Sub

 

 

下面建议你去下这个API浏览器。比较好用。
http://topic.csdn.net/thttps://files.jxasp.com/image/20040925/17/3408734.html

相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载