用vb如何检测进程中的inistr.exe是否在运行,如果运行则运行C:\1.BAT.不运行就退出。 30

用vb如何检测进程中的inistr.exe是否在运行,如果运行则运行C:\1.BAT.不运行就退出。inistr.exe没窗口的,,BAT也可以... 用vb如何检测进程中的inistr.exe是否在运行,如果运行则运行C:\1.BAT.不运行就退出。
inistr.exe没窗口的,, BAT也可以
展开
 我来答
百度网友6f0e27966
2010-04-10 · TA获得超过184个赞
知道小有建树答主
回答量:221
采纳率:0%
帮助的人:221万
展开全部
如果InitStr.exe有窗口就不用这么复杂,先用Findwindow查找该窗体是否存在,然后如果有就运行1.bat,不运行就退出。用VC里的Spy++可以捕获该窗口的类名,窗体名称就是它显示的名称
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
沙慧月03
2010-04-10 · TA获得超过2157个赞
知道大有可为答主
回答量:2717
采纳率:100%
帮助的人:3619万
展开全部
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 Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long '
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Const TH32CS_SNAPPROCESS = &H2
Private Const TH32CS_SNAPheaplist = &H1
Private Const TH32CS_SNAPthread = &H4
Private Const TH32CS_SNAPmodule = &H8
Private Const TH32CS_SNAPall = TH32CS_SNAPPROCESS + TH32CS_SNAPheaplist + TH32CS_SNAPthread + TH32CS_SNAPmodule
Private Const MAX_PATH As Integer = 260

Private Const PROCESS_ALL_ACCESS = &H100000 + &HF0000 + &HFFF

Private Type PROCESSENTRY32
dwSize As Long
cntUseage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
swFlags As Long
szExeFile As String * 1024
End Type

Private Sub Command1_Click()
Dim MySnapHandle As Long
Dim hProcess As Long
Dim ProcessInfo As PROCESSENTRY32
MySnapHandle = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0)
ProcessInfo.dwSize = Len(ProcessInfo)
If ProcessFirst(MySnapHandle, ProcessInfo) <> 0 Then
Do
If Left(LCase(ProcessInfo.szExeFile), InStr(ProcessInfo.szExeFile, ".") + 3) = "inistr.exe" Then
'遍历进程,查找inistr.exe,找到后执行操作.......
hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, ProcessInfo.th32ProcessID)
TerminateProcess hProcess, 1
CloseHandle hProcess

End If
Loop While ProcessNext(MySnapHandle, ProcessInfo) <> 0
End If
CloseHandle MySnapHandle
End Sub
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
bydosniper
2010-04-10 · TA获得超过1059个赞
知道小有建树答主
回答量:605
采纳率:100%
帮助的人:242万
展开全部
如果Instr.exe是你写的 就用DDE通信,如果不是就麻烦多了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2010-04-10
展开全部
用批处理行不?
@echo off
tasklist | find /i "inistr.exe" && start "" "C:\1.bat" ||exit
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式