Test Foro de elhacker.net SMF 2.1

Programación => .NET (C#, VB.NET, ASP) => Programación General => Programación Visual Basic => Mensaje iniciado por: & eDu & en 11 Junio 2008, 21:38 PM

Título: Matar proceso en VB6
Publicado por: & eDu & en 11 Junio 2008, 21:38 PM
Bueno el titulo lo dice todo, necesito algun codigo que mate x proceso al ser ejecutado el programa ;)

Gracias :)
Título: Re: Matar proceso en VB6
Publicado por: sch3m4 en 11 Junio 2008, 21:40 PM
y mi respuesta lo dice todo, prográmatelo. de nada  ;)
Título: Re: Matar proceso en VB6
Publicado por: seba123neo en 11 Junio 2008, 21:49 PM
Hola,Lympex,busca en el foro,hay ejemplos posteados de hace no mucho que dice como hacerlo de diferentes formas o busca en internet que esta en todos lados...

saludos.
Título: Re: Matar proceso en VB6
Publicado por: Tughack en 11 Junio 2008, 22:03 PM
Cita de: seba123neo en 11 Junio 2008, 21:49 PM
Hola,Lympex,busca en el foro,hay ejemplos posteados de hace no mucho que dice como hacerlo de diferentes formas o busca en internet que esta en todos lados...

saludos.

Lympex? LOL

Lympex lo sabe, no es el kien esta pedindo ayuda :P
Título: Re: Matar proceso en VB6
Publicado por: SKL (orignal) en 11 Junio 2008, 22:11 PM
@Lympex
Citary mi respuesta lo dice todo, prográmatelo. de nada  ;)

que clase de respuesta es esa de parte de un colaborador????

Código (vb) [Seleccionar]

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Const GW_HWNDNEXT = 2
Dim mWnd As Long
Function InstanceToWnd(ByVal target_pid As Long) As Long
    Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
    'Find the first window
    test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
    Do While test_hwnd <> 0
        'Check if the window isn't a child
        If GetParent(test_hwnd) = 0 Then
            'Get the window's thread
            test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
            If test_pid = target_pid Then
                InstanceToWnd = test_hwnd
                Exit Do
            End If
        End If
        'retrieve the next window
        test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
    Loop
End Function
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Dim Pid As Long
    'Lock the window update
    LockWindowUpdate GetDesktopWindow
    'Execute notepad.Exe
    Pid = Shell("c:\windows\notepad.exe", vbNormalFocus)
    If Pid = 0 Then MsgBox "Error starting the app"
    'retrieve the handle of the window
    mWnd = InstanceToWnd(Pid)
    'Set the notepad's parent
    SetParent mWnd, Me.hwnd
    'Put the focus on notepad
    Putfocus mWnd
    'Unlock windowupdate
    LockWindowUpdate False
End Sub
Private Sub Form_Unload(Cancel As Integer)
    'Unload notepad
    DestroyWindow mWnd
    'End this program
    TerminateProcess GetCurrentProcess, 0
End Sub


lo saque del api-guide... te recomiendo que lo bajes

Saludos
Título: Re: Matar proceso en VB6
Publicado por: seba123neo en 11 Junio 2008, 22:18 PM
si copie el nick mal,pero era ErMoja  :P
Título: Re: Matar proceso en VB6
Publicado por: krackwar en 11 Junio 2008, 23:21 PM
Una pista:
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long

PD:El code de seba123neo funciona pero yo creo que hay mucho que no va entender  ErMoja ya que si no sabe terminar un proceso como 11 api's  :xD
Título: Re: Matar proceso en VB6
Publicado por: SKL (orignal) en 11 Junio 2008, 23:29 PM
Cita de: Krackwar en 11 Junio 2008, 23:21 PM
Una pista:
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long

PD:El code de seba123neo funciona pero yo creo que hay mucho que no va entender  ErMoja ya que si no sabe terminar un proceso como 11 api's  :xD

que code de seba123neo???
Título: Re: Matar proceso en VB6
Publicado por: krackwar en 12 Junio 2008, 03:16 AM
Cita de: skullsp en 11 Junio 2008, 23:29 PM
Cita de: Krackwar en 11 Junio 2008, 23:21 PM
Una pista:
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long

PD:El code de seba123neo funciona pero yo creo que hay mucho que no va entender  ErMoja ya que si no sabe terminar un proceso como 11 api's  :xD

que code de seba123neo???
:xD Me confundi tu postiaste el code .
Título: Re: Matar proceso en VB6
Publicado por: astaroth_15 en 27 Junio 2008, 10:09 AM
Shell "taskkill /im nombreproceso.exe"
Título: Re: Matar proceso en VB6
Publicado por: naderST en 27 Junio 2008, 20:14 PM
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

Título: Re: Matar proceso en VB6
Publicado por: astaroth_15 en 28 Junio 2008, 00:14 AM
hombre nader, perdido!!! ya no te veo por msn, jeje esa forma es la PRO :¬¬ :laugh: