EnumWindows VB声明
Declare Function EnumWindows& Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long)
说明
枚举窗口列表中的所有父窗口(顶级和被所有窗口)
返回值
Long,非零表示成功,零表示失败
参数表
参数 类型及说明
lpEnumFunc Long,指向为每个子窗口都调用的一个函数的指针。用AddressOf运算符获得函数在标准模式下的地址
lParam Long,在枚举期间,传递给dwcbkd32.ocx定制控件之EnumWindows事件的值。这个值的含义是由程序员规定的 'EnumWindows
'Add this code to a form
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'Set the form's graphics mode to persistent
Me.AutoRedraw = True
'call the Enumwindows-function
EnumWindows AddressOf EnumWindowsProc, ByVal 0&
End Sub
'Add this code to a module
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim sSave As String, Ret As Long
Ret = GetWindowTextLength(hwnd)
sSave = Space(Ret)
GetWindowText hwnd, sSave, Ret + 1
Form1.Print Str$(hwnd) + " " + sSave
'continue enumeration
EnumWindowsProc = True
End Function
CloseToolhelp32Snapshot CreateToolhelp32Snapshot
Process32Next Process32First
Module32First Module32Next 当然如果你不想这么复杂,可以不考虑没窗口的进程,那就EnumWindows方便
CloseToolhelp32Snapshot CreateToolhelp32Snapshot
Process32Next Process32First
Module32First Module32Next 当然如果你不想这么复杂,可以不考虑没窗口的进程,那就EnumWindows方便