|
欢迎您注册加入!这里有您将更精采!
您需要 登录 才可以下载或查看,没有账号?注册
x
- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- 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 WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten 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 GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
- Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
- Private Const PROCESS_VM_Operation = &H8&
- Private Const PROCESS_VM_READ = &H10&
- Private Const PROCESS_VM_WRITE = &H20&
- Private Sub Timer1_Timer()
- Dim hwnd As Long
- Dim pId As Long
- Dim pHandle As Long
- hwnd = FindWindow(vbNullString, "连连看")
- GetWindowThreadProcessId hwnd, pId
- pHandle = OpenProcess(PROCESS_VM_Operation Or PROCESS_VM_READ Or PROCESS_VM_WRITE, 0, pId)
- If pHandle = 0 Then
- MsgBox "打开程序错误"
- End If
- WriteProcessMemory pHandle, &H12FEB8, 100, 1, 0& '生命
- End Sub
复制代码
以上是我学习了VB之后通过网上视频教程写的代码,程序调试没有错,前面的API声明没有错就是下面的常量声明遇到了一些问题这些常量我在API浏览器中没有找到,这是我自己加上去的,我查过资料API函数调用不当就会导致整个VB程序崩溃,管理员帮我看一下这段代码如何修改一下谢谢。 |
|