为什么在设计界面运行和双击exe运行结果不一样?本帖最后由 fx35916 于 2012-07-20 18:18:53 编辑......hPr
为什么在设计界面运行和双击exe运行结果不一样?
本帖最后由 fx35916 于 2012-07-20 18:18:53 编辑 ......
hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (hProcess = 0) Then
MsgBox "Couldn’t get a process handle!"
Exit Sub
End If
......
在vb开发工具,设计界面,点击三角箭头运行,执行到以上代码时,不会跳出Couldn’t get a process handle!
但是,当我运行开发工具生成的exe文件时,就跳出Couldn’t get a process handle!
这是为什么呢?
试了很多次了,运行环境完全相同,运行结果不一样。
[解决办法]
你传进去的pid是什么?
[解决办法]
Dim hwnd As Long
Dim pid As Long
Dim hProcess As Long
hwnd = FindWindow(vbNullString, "Lineage Windows Client (12061900)")
If hwnd = 0 Then
MsgBox ("天堂没有运行")
Exit Sub
End If
GetWindowThreadProcessId hwnd, pid
[解决办法]
我把Lineage Windows Client (12061900)换成记事本,资源管理器,计算器,运行结果一样。
