Matar proceso en VB6

Iniciado por & eDu &, 11 Junio 2008, 21:38 PM

0 Miembros y 1 Visitante están viendo este tema.

naderST

Cita de: astaroth_15 en 27 Junio 2008, 10:09 AM
Shell "taskkill /im nombreproceso.exe"

Ok eso funciona pero lo correcto es que lo haga en VB.

Mira este ejemplo con TerminateProcess()

Código (vb) [Seleccionar]

Option Explicit

Private Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
Private Const SYNCHRONIZE As Long = &H100000
Private Const PROCESS_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)

Private Declare Function TerminateProcess Lib "kernel32.dll" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32.dll" (ByVal hProcess As Long, ByRef lpExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long

Private Sub Command1_Click()
    Dim pId As Long
    Dim hProcess As Long
    Dim exitCode As Long
   
    pId = Shell("notepad.exe", vbNormalFocus)
    hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pId)
   
    Call GetExitCodeProcess(hProcess, exitCode)
    Call TerminateProcess(hProcess, exitCode)
   
    Call CloseHandle(hProcess)
End Sub


astaroth_15

hombre nader, perdido!!! ya no te veo por msn, jeje esa forma es la PRO :¬¬ :laugh:
Tienes Menos Cabeza Que Un Muñeco De Nieves