Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName 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 Const PROCESS_ALL_ACCESS = &H1F0FFF
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Sub Timer1_Timer()
Dim cc As Long
Dim cc2 As Long
Dim cc3 As Long
Dim hp As Long
cc = FindWindow(vbNullString, "QQ华夏")
If cc = 0 Then
Label1.Caption = "连接失败"
Else
Label1.Caption = "连接成功"
End If
GetWindowThreadProcessId cc, cc2
If cc2 = 0 Then
Label2.Caption = "坏的"
Else
Label2.Caption = "好的"
End If
cc3 = OpenProcess(PROCESS_ALL_ACCESS, False, cc2)
ReadProcessMemory cc3, ByVal &H198C57C, hp, 4, 0&
Label3.Caption = hp
CloseHandle hProcess
End Sub