Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function VirtualAllocEx Lib "kernel32.dll" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, llpBufferfer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long Private Declare Function VirtualFreeEx Lib "kernel32.dll" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal dwFreeType As Long) As Long Const PROCESS_ALL_ACCESS = &H1F0FFF Const MEM_COMMIT = &H1000 Const MEM_DECOMMIT = &H4000 Const PAGE_READWRITE = &H4&Const WM_USER = &H400 Const SB_GETPARTS = (WM_USER + 6) Const SB_GETTEXT = (WM_USER + 2) Private Sub Command1_Click() Dim hTargetWindow As Long Dim hStatusBar As LongDim lProcessID As Long Dim hProcess As LongDim lPartIndex As LongDim lpBuffer As Long Dim s As String * 1024hTargetWindow = FindWindowEx(0, 0, vbNullString, "Microsoft Spy++ - [Windows 1]") If hTargetWindow = 0 Then Exit SubhStatusBar = FindWindowEx(hTargetWindow, 0, "msctls_statusbar32", "") If hStatusBar = 0 Then Exit SubGetWindowThreadProcessId hTargetWindow, lProcessIDhProcess = OpenProcess(PROCESS_ALL_ACCESS, False, lProcessID) If hProcess = 0 Then Exit SublpBuffer = VirtualAllocEx(ByVal hProcess, ByVal 0&, Len(s), MEM_COMMIT, PAGE_READWRITE) If lpBuffer = 0 Then Exit SublPartIndex = 2Call SendMessage(hStatusBar, SB_GETTEXT, lPartIndex, ByVal lpBuffer)Call ReadProcessMemory(ByVal hProcess, ByVal lpBuffer, ByVal s, Len(s), ByVal 0)VirtualFreeEx hProcess, ByVal lpBuffer, 0, MEM_DECOMMITDebug.Print "状态栏"; lPartIndex + 1; "中的文字为:"; s End Sub
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function VirtualAllocEx Lib "kernel32.dll" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, llpBufferfer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32.dll" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal dwFreeType As Long) As Long
Const PROCESS_ALL_ACCESS = &H1F0FFF
Const MEM_COMMIT = &H1000
Const MEM_DECOMMIT = &H4000
Const PAGE_READWRITE = &H4&Const WM_USER = &H400
Const SB_GETPARTS = (WM_USER + 6)
Const SB_GETTEXT = (WM_USER + 2)
Private Sub Command1_Click()
Dim hTargetWindow As Long
Dim hStatusBar As LongDim lProcessID As Long
Dim hProcess As LongDim lPartIndex As LongDim lpBuffer As Long
Dim s As String * 1024hTargetWindow = FindWindowEx(0, 0, vbNullString, "Microsoft Spy++ - [Windows 1]")
If hTargetWindow = 0 Then Exit SubhStatusBar = FindWindowEx(hTargetWindow, 0, "msctls_statusbar32", "")
If hStatusBar = 0 Then Exit SubGetWindowThreadProcessId hTargetWindow, lProcessIDhProcess = OpenProcess(PROCESS_ALL_ACCESS, False, lProcessID)
If hProcess = 0 Then Exit SublpBuffer = VirtualAllocEx(ByVal hProcess, ByVal 0&, Len(s), MEM_COMMIT, PAGE_READWRITE)
If lpBuffer = 0 Then Exit SublPartIndex = 2Call SendMessage(hStatusBar, SB_GETTEXT, lPartIndex, ByVal lpBuffer)Call ReadProcessMemory(ByVal hProcess, ByVal lpBuffer, ByVal s, Len(s), ByVal 0)VirtualFreeEx hProcess, ByVal lpBuffer, 0, MEM_DECOMMITDebug.Print "状态栏"; lPartIndex + 1; "中的文字为:"; s
End Sub