Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Const GW_HWNDFIRST = 0
Const GW_HWNDNEXT = 2
Private Sub Command1_Click()
Dim s As Long
Dim a As String
a = Space(255)
s = GetWindow(Me.hwnd, GW_HWNDFIRST) '获得句柄
GetWindowText s, a, 255 '获得标题
Dim ab As String * 255
GetClassName s, ab, 255 '获得类名
Dim ClassName As String
ClassName = StripTerFlag(ab) 'StripTerFlag是一个自定义函数,后面有代码,用于去处结束符
If UCase(ClassName) = "NOTEPAD" Then
List1.AddItem a
List1.ItemData(List1.ListCount - 1) = s
End If
Do While s
DoEvents
s = GetWindow(s, GW_HWNDNEXT) '获得句柄
GetWindowText s, a, 255 '获得标题
GetClassName s, ab, 255 '获得类名
ClassName = StripTerFlag(ab)
If UCase(ClassName) = "NOTEPAD" Then
List1.AddItem a
List1.ItemData(List1.ListCount - 1) = s
End If
Loop
End Sub
Private Sub List1_Click()
MsgBox List1.ItemData(List1.ListIndex) '单击列表框获得句柄
End Sub
'StripTerFlag是一个自定义函数,后面有代码,用于去处结束符
我要StripTerFlag的定义代码
我要StripTerFlag的定义代码
我要StripTerFlag的定义代码
我要StripTerFlag的定义代码
获取窗口句柄
答案:1 悬赏:60 手机版
解决时间 2021-02-28 18:50
- 提问者网友:几叶到寒
- 2021-02-28 16:01
最佳答案
- 五星知识达人网友:人间朝暮
- 2021-02-28 16:57
function StripTerFlag(str)
StripTerFlag=replace(str,chr(0),"")
end function
可能用得起。但应该和作者写的不太一样。
StripTerFlag=replace(str,chr(0),"")
end function
可能用得起。但应该和作者写的不太一样。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯