求高手给个VB的进程监控源码
- 提问者网友:人生佛魔见
- 2021-05-14 18:15
- 五星知识达人网友:舊物识亽
- 2021-05-14 19:00
要用到api的FindWindow和SendMessage
我有,要的话,给你个做好的。
- 1楼网友:过活
- 2021-05-14 20:29
Visual Basic程序设计
教程视频
网络视频: http://pcedu.pconline.com.cn/videoedu/asp/0903/1587195.html
教学下载: http://www.gougou.com/search?search=vb%E6%95%99%E7%A8%8B&restype=-1&id=10000001&ty=0&pattern=0&xmp=0
vb软件精简版: http://down.gougou.com/down?cid=E3799F7FFB91876F1529585334604CCA359B0A73
够全了吧,一定要采纳哦!
- 2楼网友:神也偏爱
- 2021-05-14 19:49
1、先把下面内容弄到模块中。。
Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * 1024 End Type Const TH32CS_SNAPHEAPLIST = &H1 Const TH32CS_SNAPPROCESS = &H2 Const TH32CS_SNAPTHREAD = &H4 Const TH32CS_SNAPMODULE = &H8 Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE) Const TH32CS_INHERIT = &H80000000 Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
'查找进程的函数 Function fun_FindProcess(ByVal ProcessName As String) As Long Dim strdata As String Dim my As PROCESSENTRY32 Dim l As Long Dim l1 As Long Dim mName As String Dim i As Integer, pid As Long l = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) If l Then my.dwSize = 1060 If (Process32First(l, my)) Then Do i = InStr(1, my.szExeFile, Chr(0)) mName = LCase(Left(my.szExeFile, i - 1)) If mName = LCase(ProcessName) Then pid = my.th32ProcessID fun_FindProcess = pid Exit Function End If Loop Until (Process32Next(l, my) < 1) End If l1 = CloseHandle(l) End If fun_FindProcess = 0 End Function
2、if fun_FindProcess("qq.exe") <> 0 then 'QQ已经运行了。反之就是QQ没有运行。
谢谢////