Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Общий форум

Страница: 1 |

 

  Вопрос: как вырубить процессы Добавлено: 23.10.04 00:12  

Автор вопроса:  LD | ICQ: 336327056 
Люди подскажите плзз, как заставить прогу вырубать процесс или прогу по таймеру, например мне надо вырубить FlashGet в 6 часов утра,,, как?

Ответить

  Ответы Всего ответов: 2  

Номер ответа: 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()
    ;Dim threadID As Long
    ;Dim ProcessID As Long
    ;Dim hSnapshot As Long
    ;Dim uProcess As PROCESSENTRY32
    ;Dim rProcessFound As Long
    ;Dim InStrRes As Integer
    ;Dim szExename As String
    ;Dim strParentName As String
    hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&;)
    If hSnapshot = -1 Then Exit Sub
    uProcess.dwSize = Len(uProcess)
    rProcessFound = ProcessFirst(hSnapshot, uProcess)
    ;Do 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)
    ;Dim 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

Ответить

Номер ответа: 2
Автор ответа:
 HACKER


 

Разработчик Offline Client

Вопросов: 236
Ответов: 8362
 Профиль | | #2 Добавлено: 24.10.04 00:10
А можно и нажать кнопку ПОИСК в нашем скромном форуме.

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам