TerminateProcessDeclare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
解决方案 »
- 请教各位,VB6.0中,实现串口通讯时,怎样发送9位数据?
- 如何分割text1的内容?
- 请问vb2005中有网格的控件吗?
- Inet1 这个控件在哪里啊 在那里引用???
- shockwaveFlash播放swf时可不可以控制播放声音大小
- 子类化重绘仿QQ2009渐变按钮模块 代码
- 高分请教高手:如何获得其他exe程序的所有控件名及参数
- 请教如何利用API获取本地机器的上网方式,拨号连接的名称,以及发送数据的字节数和接受到数据的字节数?
- 关于多个Textbox的操作
- vb6调用webservice接口,中文参数问题,请高手赐教
- 如何改变滚动条的颜色
- 用VB编译成的程序要运行库,用Delphi编译的程序需要什么?
用GetWindowThreadProcessId取得线程标示符
用OpenProcess打开线程
用TerminateProcess终止线程
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
说明
寻找窗口列表中第一个符合指定条件的顶级窗口(在vb里使用:FindWindow最常见的一个用途是获得ThunderRTMain类的隐藏窗口的句柄;该类是所有运行中vb执行程序的一部分。获得句柄后,可用api函数GetWindowText取得这个窗口的名称;该名也是应用程序的标题)
返回值
Long,找到窗口的句柄。如未找到相符窗口,则返回零。会设置GetLastError
参数表
参数 类型及说明
lpClassName String,指向包含了窗口类名的空中止(C语言)字串的指针;或设为零,表示接收任何类
lpWindowName String,指向包含了窗口文本(或标签)的空中止(C语言)字串的指针;或设为零,表示接收任何窗口标题
注解
很少要求同时按类与窗口名搜索。为向自己不准备参数传递一个零,最简便的办法是传递vbNullString常数
示例
Dim hw&, cnt&
Dim rttitle As String * 256
hw& = FindWindow("ThunderRT5Main", vbNullString) ' ThunderRTMain under VB4
cnt = GetWindowText(hw&, rttitle, 255)
MsgBox Left$(rttitle, cnt), 0, "RTMain title" GetWindowThreadProcessId VB声明
Declare Function GetWindowThreadProcessId Lib "user32" Alias "GetWindowThreadProcessId" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
说明
获取与指定窗口关联在一起的一个进程和线程标识符
返回值
Long,拥有窗口的线程的标识符
参数表
参数 类型及说明
lpdwProcessId Long,指定一个变量,用于装载拥有那个窗口的一个进程的标识符
hwnd Long,指定窗口句柄 Declare Function OpenProcess Lib "Kernel32.dll" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long?dwDesiredAccess
[in] Specifies the access to the process object. For operating systems that support security checking, this access is checked against any security descriptor for the target process. This parameter can be STANDARD_RIGHTS_REQUIRED or one or more of the following values.
PROCESS_ALL_ACCESS
Specifies all possible access flags for the process object.
PROCESS_CREATE_PROCESS
Used internally.
PROCESS_CREATE_THREAD
Enables using the process handle in the CreateRemoteThread function to create a thread in the process.
PROCESS_DUP_HANDLE
Enables using the process handle as either the source or target process in the DuplicateHandle function to duplicate a handle.
PROCESS_QUERY_INFORMATION
Enables using the process handle in the GetExitCodeProcess and GetPriorityClass functions to read information from the process object.
PROCESS_SET_QUOTA
Enables using the process handle in the AssignProcessToJobObject and SetProcessWorkingSetSize functions to set memory limits.
PROCESS_SET_INFORMATION
Enables using the process handle in the SetPriorityClass function to set the priority class of the process.
PROCESS_TERMINATE
Enables using the process handle in the TerminateProcess function to terminate the process.
PROCESS_VM_OPERATION
Enables using the process handle in the VirtualProtectEx and WriteProcessMemory functions to modify the virtual memory of the process.
PROCESS_VM_READ
Enables using the process handle in the ReadProcessMemory function to read from the virtual memory of the process.
PROCESS_VM_WRITE
Enables using the process handle in the WriteProcessMemory function to write to the virtual memory of the process.
SYNCHRONIZE
Windows NT/2000: Enables using the process handle in any of the wait functions to wait for the process to terminate.?bInheritHandle
[in] Specifies whether the returned handle can be inherited by a new process created by the current process. If TRUE, the handle is inheritable.?dwProcessId
[in] Specifies the identifier of the process to open.
TerminateProcess VB声明
Declare Function TerminateProcess Lib "kernel32" Alias "TerminateProcess" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
说明
结束一个进程
在VB里使用
可以使用,但尽量不用
返回值
Long,非零表示成功,零表示失败。会设置GetLastError
参数表
参数 类型及说明
hProcess Long,指定要中断的一个进程的句柄
uExitCode Long,进程的一个退出代码