下面的代码在XP下无法关闭,不知道有什么问题或者有没有更好的办法
Option Explicit
Const SYNCHRONIZE = &H100000
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As LongSub main()
Dim ProcessId As Long
Dim hProcess As Long
ProcessId = Shell("notepad.exe", 1) '此处利用了 Shell当函数使用时返回的任务标识
hProcess = OpenProcess(SYNCHRONIZE, False, ProcessId)
Call TerminateProcess(hProcess, 3838)
End Sub
Option Explicit
Const SYNCHRONIZE = &H100000
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As LongSub main()
Dim ProcessId As Long
Dim hProcess As Long
ProcessId = Shell("notepad.exe", 1) '此处利用了 Shell当函数使用时返回的任务标识
hProcess = OpenProcess(SYNCHRONIZE, False, ProcessId)
Call TerminateProcess(hProcess, 3838)
End Sub
解决方案 »
- 关于activereports GroupFooter 的一个问题(很难的)
- 请高手帮忙解决WebBrowser可编辑状态时,回车时要换行却变成换段的问题?
- 复制TreeView控件?
- 还是老问题请师傅指点:关于用access作为数据库的网络运用程序
- 使用winsock做了一个点对点的聊天程序不能在一台机器上运行?
- 在2000的系统注销后,我的应用程序就不运行了,如何解决。分数不够可再加!
- VB中动态插入数据
- 运行时错误‘5’ 无效的过程参数调用或参数
- vb adodb 出现未指定的问题
- 帮小弟可以吗!!!!!各位!!!!!!
- 我用VB写了一个ActiveX OCX,在VB和VC中都能使用!为什么Delphi引入不了??????
- VB中如何编写这样的键盘事件
Const PROCESS_QUERY_INFORMATION = &H400
Const PROCESS_TERMINATE = &H1
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As LongSub main()
Dim ProcessId As Long
Dim hProcess As Long
ProcessId = Shell("notepad.exe", 1) '此处利用了 Shell当函数使用时返回的任务标识
hProcess = OpenProcess(PROCESS_TERMINATE Or PROCESS_QUERY_INFORMATION, False, ProcessId)
Call TerminateProcess(hProcess, 3838)
End Sub