转载:VB监视进程
2013-12-05 21:38
204 查看
从百度知道看的,VB监视进程:
让VB程序监视进程中的名称“Windows 任务管理器”,和“AAA”两个进程的进程名,
而且进行操作:如果“Windows 任务管理器”被关闭时则自动关闭“进程某某”程序!
可以用一个 Timer 定时执行下面的代码
让VB程序监视进程中的名称“Windows 任务管理器”,和“AAA”两个进程的进程名,
而且进行操作:如果“Windows 任务管理器”被关闭时则自动关闭“进程某某”程序!
可以用一个 Timer 定时执行下面的代码
Dim Handle As Long Handle = FindWindow(vbnullstring,"Windows 任务管理器") Dim Handle2 as long Handle2 = FindWindow(vbnullstring,"进程某某") if not (Handle) then SendMessage Handle2,WM_CLOSE,0,0 Option Explicit Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Sub Timer1_Timer() Dim Handle As Long Dim handle2 As Long Dim ProHandle As Long Dim ProcessHandle As Long Handle = FindWindow(vbNullString, "Windows 任务管理器") If Handle = 0 Then handle2 = FindWindow(vbNullString, "进程某某") GetWindowThreadProcessId handle2, ProHandle ProcessHandle = OpenProcess(1, 0, ProHandle) TerminateProcess ProcessHandle, 0 End If End Sub
相关文章推荐
- vb读出二进制文件,合并两个文件
- VB另类技巧(可以用于VBA)-指针的使用
- VB 声音提示
- vb随机显示图片
- vb中picturebox透明时看到下面的picturebox中图片
- vb中filecopy拷贝文件
- vb的一些搞怪的操作
- vb检查磁盘类型
- 怎样让VB6程序只能运行一次
- VB 日期时间函数
- VB.NET判断一个路径的文件是否存在
- VB中KeyCode常数用法 VB 按键
- vbs 正则表达式 字符说明
- vb.net中类型转换函数
- 用VB发送组合键代码
- 用VB模拟带有修饰键的组合键
- [VB.net]飞龙·网页及贴吧操作II
- Vbox 虚拟机不能显示桌面图标 解决方法
- Vbox 虚拟机不能显示桌面图标 解决方法
- VB.NET 异常处理