程序中所使用的api函数均已经声明,返回的进程号也对,但是在进行打开进程的处理时候却提示不能打开。请高手帮我看看错在哪里!!!?程序以计算器窗口进行调试。
Private Sub Command1_Click()
' 声明变量
Dim hwnd As Long ' 储存 FindWindow 函数返回的句柄
Dim pid As Long ' 储存进程标识符
Dim pHandle As Long ' 储存进程句柄
Dim str As String * 20 ' 存储显示文本' 取得目标窗口的句柄
hwnd = FindWindow(vbNullString, "计算器")
If (hwnd = 0) Then
MsgBox ("0")
Exit Sub
End If
' 取得进程标识符
GetWindowThreadProcessId hwnd, pid
MsgBox (pid)' 取得进程句柄
pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (pHandle = 0) Then
MsgBox "得不到窗口进程信息"
Exit Sub
End If