Option Explicit
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 Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal 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 Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function Beep Lib "kernel32" ( _
ByVal dwFreq As Long, _
ByVal dwDuration As Long) As Long
Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
Private Function Hex2Dec(sText As String) As Long
On Error GoTo err
Dim H As String
H = sText
Dim Tmp$
Dim lo1 As Integer, lo2 As Integer
Dim hi1 As Long, hi2 As Long
Const Hx = "&H"
Const BigShift = 65536
Const LilShift = 256, Two = 2
Tmp = H
If UCase(Left$(H, 2)) = "&H" Then Tmp = Mid$(H, 3)
Tmp = Right$("0000000" & Tmp, 8)
If IsNumeric(Hx & Tmp) Then
lo1 = CInt(Hx & Right$(Tmp, Two))
hi1 = CLng(Hx & Mid$(Tmp, 5, Two))
lo2 = CInt(Hx & Mid$(Tmp, 3, Two))
hi2 = CLng(Hx & Left$(Tmp, Two))
Hex2Dec = CCur(hi2 * LilShift + lo2) * BigShift + (hi1 * LilShift) + lo1
End If
Exit Function
err:
End Function
Private Sub ReadTimer_Timer()
Dim W
' Объявляем некоторые необходимые моменты для таймера.
Dim hwnd As Long ' удерживает управление, переданное функцией FindWindow.
Dim pid As Long ' удерживает идентификатор процесса.
Dim pHandle As Long ' удерживает управление процессом.
Dim str As String * 20 ' параметр текстовой строки.
' Вначале ищем окно игры.
hwnd = FindWindow(vbNullString, "GTA: San Andreas")
If (hwnd = 0) Then hwnd = FindWindow(vbNullString, "GTA: San Andreas")
If (hwnd = 0) Then Exit Sub
' Теперь можно определить идентификатор процесса.
GetWindowThreadProcessId hwnd, pid
' Используем идентификатор для управления процессом.
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (pHandle = 0) Then Exit Sub
' Теперь можно прочитать из памяти...
W = Hex2Dec("52CF53")
ReadProcessMemory pHandle, Hex2Dec("52CF53"), str, Len(Hex2ASCII("FE 05 52 01 B7 00")), 0&
''... и показать строку в текстовом поле трейнера.
txtDisplay.text = str
' Прекращаем управлять процессом.
CloseHandle pHandle
End Sub
Уже написали. Где-то на www.vb.kiev.ua натыкался.
Сейчас этот форум просматривают: SemrushBot и гости: 74