求VB高手进来帮下忙
答案:2 悬赏:20 手机版
解决时间 2021-05-04 23:55
- 提问者网友:聂風
- 2021-05-04 11:50
我想 会的近来帮下忙拉`谢谢
最佳答案
- 五星知识达人网友:掌灯师
- 2021-05-04 12:59
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim hw As Long, cnt As Long
Dim rttitle As String * 256
hw = FindWindow("窗口名", vbNullString)
If hw = 0 then
MsgBox "找不到指定窗口"
End If
全部回答
- 1楼网友:鱼忧
- 2021-05-04 14:30
看下面代码
需要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我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯