Страница: 1 |
|
Вопрос: как вырубить процессы
|
Добавлено: 23.10.04 00:12
|
|
Автор вопроса: LD | ICQ: 336327056
|
Люди подскажите плзз, как заставить прогу вырубать процесс или прогу по таймеру, например мне надо вырубить FlashGet в 6 часов утра,,, как?
Ответить
|
Номер ответа: 1 Автор ответа: Mihalыch
ICQ: 373-509-101
Вопросов: 56 Ответов: 330
|
Профиль | | #1
|
Добавлено: 23.10.04 02:50
|
Можно так:
Option Explicit
Private Const MAX_PATH As Long = 260
Private Const TH32CS_SNAPPROCESS As Long = 2&
Private Const PROCESS_TERMINATE = &H1
Private Type PROCINF
CurrProcName As String
CurrProcID As Long
ParentProcName As String
ParentProcID As Long
End Type
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 * MAX_PATH
End Type
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Private Declare Function CreateToolhelpSnapshot Lib "Kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlgas 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 Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)
Private Declare Function TerminateProcess Lib "Kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Sub ProcList()
 im threadID As Long
 im ProcessID As Long
 im hSnapshot As Long
 im uProcess As PROCESSENTRY32
 im rProcessFound As Long
 im InStrRes As Integer
 im szExename As String
 im strParentName As String
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&
If hSnapshot = -1 Then Exit Sub
uProcess.dwSize = Len(uProcess)
rProcessFound = ProcessFirst(hSnapshot, uProcess)
 o While rProcessFound
If Left(uProcess.szExeFile, 12) = "flashget.exe" Then
KillProc uProcess.th32ProcessID
End If
rProcessFound = ProcessNext(hSnapshot, uProcess)
Loop
Call CloseHandle(hSnapshot)
End Sub
Sub KillProc(ByVal ProcID As Long)
 im hProcess As Long
hProcess = OpenProcess(PROCESS_TERMINATE, 1&, ProcID)
TerminateProcess hProcess, 0
Call CloseHandle(hProcess)
End Sub
Private Sub Timer1_Timer()
If FormatDateTime(Time, vbShortTime) = CDate("6:00" Then ProcList
End Sub
Ответить
|
Страница: 1 |
Поиск по форуму