|
SQABasic中没有提供你需要的简单的命令!
Try the following, just copy/paste into a new .rec file set to terminate all iexplore.exe processes.
Const PROCESS_QUERY_INFORMATION = 1024
Const PROCESS_VM_READ = 16
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)
Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long ' This process
th32DefaultHeapID As Long
th32ModuleID As Long ' Associated exe
cntThreads As Long
th32ParentProcessID As Long ' This process's parent process
pcPriClassBase As Long ' Base priority of process threads
dwFlags As Long
szExeFile As String * 260 ' MAX_PATH
End Type
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function TerminateProcess& Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long)
Declare Function CreateToolhelp32Snapshot Lib "Kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Declare Function Process32First Lib "Kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Declare Function Process32Next Lib "Kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)
Sub Main
Dim lProcID as long
Dim Result
Dim hSnapShot As Long
Dim uProcess As PROCESSENTRY32
Dim sApplication as String
sApplication = "IEXPLORE.EXE"
'Takes a snapshot of the processes
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&)
'set the length
uProcess.dwSize = Len(uProcess)
'Get the first process in snapshot
Result = Process32First(hSnapShot, uProcess)
Do While Result
If InStr(1, uProcess.szExeFile, Chr$(0)) > 0 Then
'Is this the application we're looking for?
If InStr(1, uProcess.szExeFile, sApplication) Then
'If so, then open the process and get it's Proc ID so we can KILL IT
lProcID = OpenProcess(PROCESS_QUERY_INFORMATION Or _
PROCESS_VM_READ, 0, uProcess.th32ProcessID)
'KILL IT
TerminateProcess lProcID, 0
End If
End If
'Just writing to console for prosperity
sqaconsolewrite uProcess.szExeFile
'Get the next process in snapshot
Result = Process32Next(hSnapShot, uProcess)
Loop
'close our snapshot handle
CloseHandle hSnapShot
End Sub |
|