Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

blac3r

me

Recommended Posts

Option ExplicitPublic Const TH32CS_SNAPPROCESS As Long = 2&Public Const MAX_PATH As Long = 260Public 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_PATHEnd TypePublic Const PROCESS_ALL_ACCESS As Long = &H1F0FFFPublic Declare Function CreateToolhelp32Snapshot Lib "kernel32" _   (ByVal lFlags As Long, ByVal lProcessID As Long) As LongPublic Declare Function ProcessFirst Lib "kernel32" _    Alias "Process32First" _   (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As LongPublic Declare Function ProcessNext Lib "kernel32" _    Alias "Process32Next" _   (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As LongPublic Declare Function OpenProcess Lib "kernel32" _   (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _    ByVal dwProcessId As Long) As LongPublic Declare Function TerminateProcess Lib "kernel32" _   (ByVal hProcess As Long, ByVal uExitCode As Long) As LongPublic Declare Sub CloseHandle Lib "kernel32" _   (ByVal hPass As Long)Public Function CloseProcess(EXEName As String) As Boolean   Dim hSnapShot  As Long   Dim uProcess   As PROCESSENTRY32   Dim hProcess   As Long   CloseProcess = False   hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)   If hSnapShot = -1 Then Exit Function   uProcess.dwSize = Len(uProcess)   If ProcessFirst(hSnapShot, uProcess) = 1 Then      Do         If LCase$(Left$(uProcess.szExeFile, InStr(1, uProcess.szExeFile, vbNullChar) - 1)) = LCase$(EXEName) Then            hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, uProcess.th32ProcessID)            CloseProcess = TerminateProcess(hProcess, ByVal 0&) > 0            Exit Do         End If      Loop While ProcessNext(hSnapShot, uProcess)   End If   Call CloseHandle(hSnapShot)End Function

PS: Retirado da Internet

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.