VB 判断进程是否在

假如我要判断ss.exe这个进程,如果这个进程终止了的话就运行dd.exe这个文件来激活ss.exe这个进程,我的意思就是要让进程里面一直都有ss.exe这个进程!... 假如我要判断ss.exe这个进程,如果这个进程终止了的话就运行dd.exe这个文件来激活ss.exe这个进程,我的意思就是要让进程里面一直都有ss.exe 这个进程! 展开
 我来答
明桖瑶gr
2007-04-12 · TA获得超过1205个赞
知道小有建树答主
回答量:397
采纳率:100%
帮助的人:620万
展开全部
枚举系统进程....

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

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long

Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long

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

Private Const TH32CS_SNAPHEAPLIST = &H1

Private Const TH32CS_SNAPPROCESS = &H2

Private Const TH32CS_SNAPTHREAD = &H4

Private Const TH32CS_SNAPMODULE = &H8

Private Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)

Private Const TH32CS_INHERIT = &H80000000

Private Sub EnumProcess
Dim process As PROCESSENTRY32
Dim l As Long
Dim l1 As Long
Dim mName As String

Dim I As Integer
l = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)

If l Then
process.dwSize = 1060

If (Process32First(l, process)) Then

Do
'你的程序代码
'访问 process 结构体对像获取进程信息
'在此处判断 ss.exe 是否存在,若不存在调用 ShellExecute 或 CreateProcess 函数启动,这两个函数的申明你用“API浏览器”生成一下我就不写了。

Loop Until (Process32Next(l, process) < 1)
End If

l1 = CloseHandle(l)
End If
End Sub
qjydq
2007-04-12
知道答主
回答量:23
采纳率:0%
帮助的人:5.4万
展开全部
使用API ,FindWindow一直检查这个进程是否存在,如果不存在就使用shell运行它。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式