everyone 发表于 2009-9-3 13:55:59

openprocess一直返回为空 郁闷

<p>代码如下 望高人指点</p>
<p><font face="Verdana">Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long<br/>Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer<br/>Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long<br/>Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long<br/>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<br/>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<br/>Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long</font></p>
<p>&nbsp;</p>
<p><font face="Verdana">Private Sub Timer3_Timer()<br/>Dim hwnd As Long<br/>Dim a As Long<br/>'hwnd = FindWindow(vbNullString, "Maplestory")<br/>hwnd = FindWindow(vbNullString, "计算器")<br/>If hwnd &lt;&gt; 0 Then<br/>Label1.Caption = "冒险已经启动"<br/>Else<br/>Label1.Caption = "请启动冒险岛"<br/>End If<br/>GetWindowThreadProcessId hwnd, id<br/>hProces1 = OpenProcess(PROCESS_VM_READ, 0, id)<br/>Text1.Text = hProces1<br/>End Sub</font></p>
<p>用户是管理员 杀毒也关了 就是返回一直是0 </p>

马大哈 发表于 2009-9-3 15:40:23

<p>OpenProcess之后马上调用一下getlasterror,再将返回值送入<font face="Verdana">GetRetMessage</font>函数:</p>
<p>&nbsp;</p>
<p><font face="Verdana"><a href="http://www.m5home.com/bbs/viewthread.php?tid=2509">http://www.m5home.com/bbs/viewthread.php?tid=2509</a></font></p>
<p>&nbsp;</p>
<p>就可以知道实际的错误是什么.</p>
页: [1]
查看完整版本: openprocess一直返回为空 郁闷