程序代码如下,单击command1可以运行CityOnMap_Raise.exe可是为什么我单击command2结束不了它呢?希望高手指点一下,谢谢!!!
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwdesiredaccess As Long, _
ByVal hinherithandle As Long, ByVal dwprocessecid As Long) As Long
Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess _
As Long, ByVal uExitCode As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Dim a As Long
Dim hprogram As Long
Private Sub Command1_Click()
a = Shell("C:\Program Files\城际高科\Raise\CityOnMap_Raise.exe", vbNormalFocus)End SubPrivate Sub Command2_Click()
hprogram = OpenProcess(0, False, a)
TerminateProcess hprogram, 0
If Not hprogram = 0 Then
MsgBox "runing"
Else
MsgBox "close"
End If
CloseHandle (a)
End Sub
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwdesiredaccess As Long, _
ByVal hinherithandle As Long, ByVal dwprocessecid As Long) As Long
Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess _
As Long, ByVal uExitCode As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Dim a As Long
Dim hprogram As Long
Private Sub Command1_Click()
a = Shell("C:\Program Files\城际高科\Raise\CityOnMap_Raise.exe", vbNormalFocus)End SubPrivate Sub Command2_Click()
hprogram = OpenProcess(0, False, a)
TerminateProcess hprogram, 0
If Not hprogram = 0 Then
MsgBox "runing"
Else
MsgBox "close"
End If
CloseHandle (a)
End Sub
解决方案 »
- 求助:用友畅捷通T6中,MRP采购计划列表是从哪个数据表引出的数据
- 用create table生成表的问题?
- 请问哪里能下载一个ip地址数据库?
- 谁能给我贴段控制光驱弹出/关闭的代码来?急用,谢谢!
- 结构->写入文件->读回->字符内容不一样->奇怪
- 两个 SQL Server 之间的数据交换遇到问题
- 我的msdn坏了,谁能告诉我OUPUT的语法规则?
- What is the meaning of "mb"=========================
- 声道的控制?
- 又一难题,如何使n*m个image组合显示一个图像?
- DataGrid怎么跟文本框关联
- vb6中打印.bmp图形时,横向正常,纵向压缩的厉害
你设置断点看看hprogram = OpenProcess(0, False, a)这句执行完以后hprogram取到值没有,如果是0的话试试提升你的程序的权限,或者换用别的方法。
hprogram = OpenProcess(1&, False, a)
TerminateProcess hprogram, 0
If Not hprogram = 0 Then
MsgBox "runing"
Else
MsgBox "close"
End If
CloseHandle (a)
End Sub 这样试试