请教一个问题:下面这些代码在win98中正常,但在win2000下却不行
下面这些代码在win98中正常,但在win2000下却不行,openprocess总是返回0,不知怎么回事,朋友们帮我看一下,非常感谢!
'在标准模块中
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
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
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
'在窗体中
Dim gamehwnd As Long
Dim pid As Long
Dim pHandle As Long
gamehwnd = FindWindow("PTK Window Class", vbNullString)
If (gamehwnd = 0) Then
'Debug.Print "程序未运行!"
Exit Sub
End If
GetWindowThreadProcessId gamehwnd, pid
'Debug.Print pid
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (pHandle = 0) Then
Debug.Print "无法获得进程句柄!"
Exit Sub
End If
WriteProcessMemory pHandle, &H1EF7318, ChrB$(9), 1, 0&
CloseHandle hProcess