怎样查看在运行的进程?
我想用VB程序做一个查看某个程序是否在运行,请教下是否就是查看是否有这个进程在运行就OK了.如果要查看是否有某个进程我具体应该怎样做啊.
[解决办法]
Option ExplicitPrivate Type PROCESSENTRY32dwSize As LongcntUsage As Longth32ProcessID As Longth32DefaultHeapID As Longth32ModuleID As LongcntThreads As Longth32ParentProcessID As LongpcPriClassBase As LongdwFlags As LongszExeFile As String * 260End TypePrivate Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As LongPrivate Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As LongPrivate Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, lppe As PROCESSENTRY32) As LongPrivate Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As LongPrivate Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As LongPrivate Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)Private Const TH32CS_SNAPPROCESS = &H2&Private Sub FindProcess(sProcess As String)Dim lSnapShot As LongDim bl As BooleanDim lNextProcess As LongDim tPE As PROCESSENTRY32lSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)If lSnapShot <> -1 ThentPE.dwSize = Len(tPE)lNextProcess = Process32First(lSnapShot, tPE)bl = FalseDo While lNextProcessIf LCase$(sProcess) = LCase$(Left(tPE.szExeFile, InStr(1, tPE.szExeFile, Chr(0)) - 1)) ThenMsgBox "进程正在运行!"bl = TrueExit DoEnd IflNextProcess = Process32Next(lSnapShot, tPE)LoopCloseHandle (lSnapShot)End IfIf bl = False Then MsgBox "该进程没运行!"End SubPrivate Sub Command1_Click() FindProcess "iexplore.exe"'查找iexplore.exe进程End Sub