📄 module1.bas
字号:
Attribute VB_Name = "Module1"
'Hi,
'I wanted to get the contents of edit class of any app I wanted but couldnt
'get any program to do it.I tried Spy++(utility that comes with VC++)but it
'also dont show the contents of edit class, maybe for security reasons :)
'Well I searched and found that my favourite API function SendMessage has
'the power to do just that. In this project I'v demonstrated this.
'A program called WinSight that comes with Borlands'
'Delphi or CBuilder also shows the contents of edit class.
'This project is for the educational purpose only,which demonstrates the use of
'API calls, any use of it is at your own risk and the author takes no
'responsibility of any harm or damages that maybe caused by the use of this
'source code.
'Dont forget to visit my website -> http://go.to/abubakar
' --- Author Muhammad Abubakar
' <joehacker@yahoo.com>
'------------------------------------------------------------------------------
Option Explicit
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Any) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_GETTEXT = &HD
Public Const WM_GETTEXTLENGTH = &HE
Public Icount As Integer
'Procedure to enumerate child windows
'the following functions "WndEnumProc" & "WndEnumChildProc"
'are application defined, which means that they are defined by the
'programmer him/her self. They are actually required by the 'callback'
'function, EnumWindows & EnumChildWindows in this case. One more point
'to note is that we pass the 'address' of our app-defined functions
'to the call back function through 'AddressOf' operator. Its a condition
'of AddressOf operator that the function whose address is passed should
'be in a '*.bas' file which is module ofcourse.
Public Function WndEnumChildProc(ByVal hwnd As Long, ByVal lParam As ListView) As Long
Dim bRet As Long
Dim myStr As String * 50
bRet = GetClassName(hwnd, myStr, 50)
'if you want the text for only Edit class then use the if statement:
'If (Left(myStr, 4) = "Edit") Then
'You can sort the enumerated windows into the listview control but
'I would recommend not to do so bcuz its also worth learning the order
'in which windows does the enumeration.
lParam.ListItems.Add.Text = Str(hwnd)
lParam.ListItems.Item(Icount).SubItems(1) = myStr
lParam.ListItems.Item(Icount).SubItems(2) = GetText(hwnd)
Icount = Icount + 1
'End If
WndEnumChildProc = 1
End Function
'Get the text of any window
Function GetText(Ihwnd As Long) As String
Dim Textlen As Long
Dim Text As String
Textlen = SendMessage(Ihwnd, WM_GETTEXTLENGTH, 0, 0)
If Textlen = 0 Then
GetText = ">No text for this class<"
Exit Function
End If
Textlen = Textlen + 1
Text = Space$(Textlen)
Textlen = SendMessage(Ihwnd, WM_GETTEXT, Textlen, ByVal Text)
GetText = Left$(Text, Textlen)
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -