是一个列出所有类名,进程的工具,界面跟WINDOWS的浏览器差不多,非常有用.另外给你个工具. #If Win16 Then Private Declare Sub GetCursorPos Lib "User" (lpPoint As Long) Private Declare Function WindowFromPoint Lib "User" (ByVal ptScreen _ As Any) As Integer Private Declare Function GetModuleFileName Lib "Kernel" (ByVal _ hModule As Integer, ByVal lpFileName As String, ByVal nSize As _ Integer) As Integer Private Declare Function GetWindowWord Lib "User" (ByVal hwnd As _ Integer, ByVal nIndex As Integer) As Integer Private Declare Function GetWindowLong Lib "User" (ByVal hwnd As _ Integer, ByVal nIndex As Integer) As Long Private Declare Function GetParent Lib "User" (ByVal hwnd As _ Integer) As Integer Private Declare Function GetClassName Lib "User" (ByVal hwnd As _ Integer, ByVal lpClassName As String, ByVal nMaxCount As _ Integer) As Integer Private Declare Function GetWindowText Lib "User" (ByVal hwnd As _ Integer, ByVal lpString As String, ByVal aint As Integer) As _ Integer #ElseIf Win32 Then Private Type POINTAPI X As Long Y As Long End Type Private Declare Function GetCursorPos Lib "user32" (lpPoint As _ POINTAPI) As Long Private Declare Function WindowFromPointXY Lib "user32" Alias _ "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) _ As Long Private Declare Function GetModuleFileName Lib "kernel32" Alias _ "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As _ String, ByVal nSize As Long) As Long Private Declare Function GetWindowWord Lib "user32" (ByVal hwnd As _ Long, ByVal nIndex As Long) As Integer Private Declare Function GetWindowLong Lib "user32" Alias _ "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As _ Long Private Declare Function GetParent Lib "user32" (ByVal hwnd 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 Private Declare Function GetWindowText Lib "user32" Alias _ "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, _ ByVal cch As Long) As Long #End If Const GWW_HINSTANCE = (-6) Const GWW_ID = (-12) Const GWL_STYLE = (-16) Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) Private Sub Form_Load() rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3) End SubPrivate Sub Timer1_Timer() #If Win16 Then Dim ptCursor As Long Dim sWindowText As String * 100 Dim sClassName As String * 100 Dim hWndOver As Integer Dim hWndParent As Integer Dim sParentClassName As String * 100 Dim wID As Integer Dim lWindowStyle As Long Dim hInstance As Integer Dim sParentWindowText As String * 100 Dim sModuleFileName As String * 100 Static hWndLast As Integer Call GetCursorPos(ptCursor) ' Get cursor position hWndOver = WindowFromPoint(ptCursor) ' Get window cursor is over If hWndOver <> hWndLast Then ' If changed update display hWndLast = hWndOver ' Save change Cls ' Clear the form Print "Window Handle: &H"; Hex(hWndOver) ' Display window handle r = GetWindowText(hWndOver, sWindowText, 100) ' Window text Print "Window Text: " & Left(sWindowText, r) r = GetClassName(hWndOver, sClassName, 100) ' Window Class Print "Window Class Name: "; Left(sClassName, r) lWindowStyle = GetWindowLong(hWndOver, GWL_STYLE) ' Window Style Print "Window Style: &H"; Hex(lWindowStyle) ' Get handle of parent window: hWndParent = GetParent(hWndOver) ' If there is a parent get more info: If hWndParent <> 0 Then ' Get ID of window: wID = GetWindowWord(hWndOver, GWW_ID) Print "Window ID Number: &H"; Hex(wID) Print "Parent Window Handle: &H"; Hex(hWndParent) ' Get the text of the Parent window: r = GetWindowText(hWndParent, sParentWindowText, 100) Print "Parent Window Text: " & Left(sParentWindowText, r) ' Get the class name of the parent window: r = GetClassName(hWndParent, sParentClassName, 100) Print "Parent Window Class Name: "; Left(sParentClassName, r) Else ' Update fields when no parent: Print "Window ID Number: N/A" Print "Parent Window Handle: N/A" Print "Parent Window Text : N/A" Print "Parent Window Class Name: N/A" End If ' Get window instance: hInstance = GetWindowWord(hWndOver, GWW_HINSTANCE) ' Get module file name: r = GetModuleFileName(hInstance, sModuleFileName, 100) Print "Module: "; Left(sModuleFileName, r) End If #ElseIf Win32 Then Dim pt32 As POINTAPI Dim ptx As Long Dim pty As Long Dim sWindowText As String * 100 Dim sClassName As String * 100 Dim hWndOver As Long Dim hWndParent As Long Dim sParentClassName As String * 100 Dim wID As Long Dim lWindowStyle As Long Dim hInstance As Long Dim sParentWindowText As String * 100 Dim sModuleFileName As String * 100 Static hWndLast As Long Call GetCursorPos(pt32) ' Get cursor position ptx = pt32.X pty = pt32.Y hWndOver = WindowFromPointXY(ptx, pty) ' Get window cursor is over If hWndOver <> hWndLast Then ' If changed update display hWndLast = hWndOver ' Save change Cls ' Clear the form Print "Window Handle: &H"; Hex(hWndOver) ' Display window handle r = GetWindowText(hWndOver, sWindowText, 100) ' Window text Print "Window Text: " & Left(sWindowText, r) r = GetClassName(hWndOver, sClassName, 100) ' Window Class Print "Window Class Name: "; Left(sClassName, r) lWindowStyle = GetWindowLong(hWndOver, GWL_STYLE) ' Window Style Print "Window Style: &H"; Hex(lWindowStyle) ' Get handle of parent window: hWndParent = GetParent(hWndOver) ' If there is a parent get more info: If hWndParent <> 0 Then ' Get ID of window: wID = GetWindowWord(hWndOver, GWW_ID) Print "Window ID Number: &H"; Hex(wID) Print "Parent Window Handle: &H"; Hex(hWndParent) ' Get the text of the Parent window: r = GetWindowText(hWndParent, sParentWindowText, 100) Print "Parent Window Text: " & Left(sParentWindowText, r) ' Get the class name of the parent window: r = GetClassName(hWndParent, sParentClassName, 100) Print "Parent Window Class Name: "; Left(sParentClassName, r) Else ' Update fields when no parent: Print "Window ID Number: N/A" Print "Parent Window Handle: N/A" Print "Parent Window Text : N/A" Print "Parent Window Class Name: N/A" End If ' Get window instance: hInstance = GetWindowWord(hWndOver, GWW_HINSTANCE) ' Get module file name: r = GetModuleFileName(hInstance, sModuleFileName, 100) Print "Module: "; Left(sModuleFileName, r) End If #End If End Sub
没用过能介绍一下吗?
#If Win16 Then
Private Declare Sub GetCursorPos Lib "User" (lpPoint As Long)
Private Declare Function WindowFromPoint Lib "User" (ByVal ptScreen _
As Any) As Integer
Private Declare Function GetModuleFileName Lib "Kernel" (ByVal _
hModule As Integer, ByVal lpFileName As String, ByVal nSize As _
Integer) As Integer
Private Declare Function GetWindowWord Lib "User" (ByVal hwnd As _
Integer, ByVal nIndex As Integer) As Integer
Private Declare Function GetWindowLong Lib "User" (ByVal hwnd As _
Integer, ByVal nIndex As Integer) As Long
Private Declare Function GetParent Lib "User" (ByVal hwnd As _
Integer) As Integer
Private Declare Function GetClassName Lib "User" (ByVal hwnd As _
Integer, ByVal lpClassName As String, ByVal nMaxCount As _
Integer) As Integer
Private Declare Function GetWindowText Lib "User" (ByVal hwnd As _
Integer, ByVal lpString As String, ByVal aint As Integer) As _
Integer #ElseIf Win32 Then
Private Type POINTAPI
X As Long
Y As Long
End Type Private Declare Function GetCursorPos Lib "user32" (lpPoint As _
POINTAPI) As Long
Private Declare Function WindowFromPointXY Lib "user32" Alias _
"WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) _
As Long
Private Declare Function GetModuleFileName Lib "kernel32" Alias _
"GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As _
String, ByVal nSize As Long) As Long
Private Declare Function GetWindowWord Lib "user32" (ByVal hwnd As _
Long, ByVal nIndex As Long) As Integer
Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As _
Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd 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
Private Declare Function GetWindowText Lib "user32" Alias _
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, _
ByVal cch As Long) As Long
#End If
Const GWW_HINSTANCE = (-6)
Const GWW_ID = (-12)
Const GWL_STYLE = (-16)
Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Sub Form_Load()
rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
End SubPrivate Sub Timer1_Timer()
#If Win16 Then
Dim ptCursor As Long
Dim sWindowText As String * 100
Dim sClassName As String * 100
Dim hWndOver As Integer
Dim hWndParent As Integer
Dim sParentClassName As String * 100
Dim wID As Integer
Dim lWindowStyle As Long
Dim hInstance As Integer
Dim sParentWindowText As String * 100
Dim sModuleFileName As String * 100
Static hWndLast As Integer
Call GetCursorPos(ptCursor) ' Get cursor position
hWndOver = WindowFromPoint(ptCursor) ' Get window cursor is over
If hWndOver <> hWndLast Then ' If changed update display
hWndLast = hWndOver ' Save change
Cls ' Clear the form
Print "Window Handle: &H"; Hex(hWndOver) ' Display window handle
r = GetWindowText(hWndOver, sWindowText, 100) ' Window text
Print "Window Text: " & Left(sWindowText, r)
r = GetClassName(hWndOver, sClassName, 100) ' Window Class
Print "Window Class Name: "; Left(sClassName, r)
lWindowStyle = GetWindowLong(hWndOver, GWL_STYLE) ' Window Style
Print "Window Style: &H"; Hex(lWindowStyle)
' Get handle of parent window:
hWndParent = GetParent(hWndOver)
' If there is a parent get more info:
If hWndParent <> 0 Then
' Get ID of window:
wID = GetWindowWord(hWndOver, GWW_ID)
Print "Window ID Number: &H"; Hex(wID)
Print "Parent Window Handle: &H"; Hex(hWndParent)
' Get the text of the Parent window:
r = GetWindowText(hWndParent, sParentWindowText, 100)
Print "Parent Window Text: " & Left(sParentWindowText, r)
' Get the class name of the parent window:
r = GetClassName(hWndParent, sParentClassName, 100)
Print "Parent Window Class Name: "; Left(sParentClassName, r)
Else ' Update fields when no parent:
Print "Window ID Number: N/A"
Print "Parent Window Handle: N/A"
Print "Parent Window Text : N/A"
Print "Parent Window Class Name: N/A"
End If
' Get window instance:
hInstance = GetWindowWord(hWndOver, GWW_HINSTANCE)
' Get module file name:
r = GetModuleFileName(hInstance, sModuleFileName, 100)
Print "Module: "; Left(sModuleFileName, r)
End If
#ElseIf Win32 Then
Dim pt32 As POINTAPI
Dim ptx As Long
Dim pty As Long
Dim sWindowText As String * 100
Dim sClassName As String * 100
Dim hWndOver As Long
Dim hWndParent As Long
Dim sParentClassName As String * 100
Dim wID As Long
Dim lWindowStyle As Long
Dim hInstance As Long
Dim sParentWindowText As String * 100
Dim sModuleFileName As String * 100
Static hWndLast As Long
Call GetCursorPos(pt32) ' Get cursor position
ptx = pt32.X
pty = pt32.Y
hWndOver = WindowFromPointXY(ptx, pty) ' Get window cursor is over
If hWndOver <> hWndLast Then ' If changed update display
hWndLast = hWndOver ' Save change
Cls ' Clear the form
Print "Window Handle: &H"; Hex(hWndOver) ' Display window handle
r = GetWindowText(hWndOver, sWindowText, 100) ' Window text
Print "Window Text: " & Left(sWindowText, r)
r = GetClassName(hWndOver, sClassName, 100) ' Window Class
Print "Window Class Name: "; Left(sClassName, r)
lWindowStyle = GetWindowLong(hWndOver, GWL_STYLE) ' Window Style
Print "Window Style: &H"; Hex(lWindowStyle)
' Get handle of parent window:
hWndParent = GetParent(hWndOver)
' If there is a parent get more info:
If hWndParent <> 0 Then
' Get ID of window:
wID = GetWindowWord(hWndOver, GWW_ID)
Print "Window ID Number: &H"; Hex(wID)
Print "Parent Window Handle: &H"; Hex(hWndParent)
' Get the text of the Parent window:
r = GetWindowText(hWndParent, sParentWindowText, 100)
Print "Parent Window Text: " & Left(sParentWindowText, r)
' Get the class name of the parent window:
r = GetClassName(hWndParent, sParentClassName, 100)
Print "Parent Window Class Name: "; Left(sParentClassName, r)
Else ' Update fields when no parent:
Print "Window ID Number: N/A"
Print "Parent Window Handle: N/A"
Print "Parent Window Text : N/A"
Print "Parent Window Class Name: N/A"
End If
' Get window instance:
hInstance = GetWindowWord(hWndOver, GWW_HINSTANCE)
' Get module file name:
r = GetModuleFileName(hInstance, sModuleFileName, 100)
Print "Module: "; Left(sModuleFileName, r)
End If
#End If
End Sub