module1.bas
来自「枚举所有句柄 可以获取当前所有窗体的 柄局」· BAS 代码 · 共 29 行
BAS
29 行
Attribute VB_Name = "Module1"
'**************************************************
'模块代码:Module1.bas
'**************************************************
Option Explicit
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim lpBuffer As String * 1024
Dim dwWindowCaption As String
Dim lpLength As Long
lpLength = GetWindowText(hwnd, lpBuffer, 1024)
dwWindowCaption = Left(lpBuffer, lpLength)
Form1.List1.AddItem dwWindowCaption & "[" & hwnd & "]"
If InStr(dwWindowCaption, "旺旺") > 0 Then
'停止查找函数返回0
EnumWindowsProc = 0
MsgBox hwnd
Else
'继续查找函数返回1
EnumWindowsProc = 1
End If
End Function
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?