请教一个问题:下面这些代码在win98中正常,但在win2000下却不行

kingcom 2001-03-05 10:22:00
下面这些代码在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
...全文
63 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
y1g1y1 2001-03-06
  • 打赏
  • 举报
回复
是不是某些函数不支持NT?请查看袁飞WIN32API超级工具.

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧