Foro de elhacker.net

Programación => 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
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
Citar
y mi respuesta lo dice todo, prográmatelo. de nada  ;)

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

Código
  1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
  2. Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
  3. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
  4. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
  5. Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
  6. Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
  7. Private Declare Function GetDesktopWindow Lib "user32" () As Long
  8. Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
  9. Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  10. Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
  11. Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
  12. Const GW_HWNDNEXT = 2
  13. Dim mWnd As Long
  14. Function InstanceToWnd(ByVal target_pid As Long) As Long
  15.    Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
  16.    'Find the first window
  17.    test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
  18.    Do While test_hwnd <> 0
  19.        'Check if the window isn't a child
  20.        If GetParent(test_hwnd) = 0 Then
  21.            'Get the window's thread
  22.            test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
  23.            If test_pid = target_pid Then
  24.                InstanceToWnd = test_hwnd
  25.                Exit Do
  26.            End If
  27.        End If
  28.        'retrieve the next window
  29.        test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
  30.    Loop
  31. End Function
  32. Private Sub Form_Load()
  33.    'KPD-Team 1999
  34.    'URL: http://www.allapi.net/
  35.    'E-Mail: KPDTeam@Allapi.net
  36.    Dim Pid As Long
  37.    'Lock the window update
  38.    LockWindowUpdate GetDesktopWindow
  39.    'Execute notepad.Exe
  40.    Pid = Shell("c:\windows\notepad.exe", vbNormalFocus)
  41.    If Pid = 0 Then MsgBox "Error starting the app"
  42.    'retrieve the handle of the window
  43.    mWnd = InstanceToWnd(Pid)
  44.    'Set the notepad's parent
  45.    SetParent mWnd, Me.hwnd
  46.    'Put the focus on notepad
  47.    Putfocus mWnd
  48.    'Unlock windowupdate
  49.    LockWindowUpdate False
  50. End Sub
  51. Private Sub Form_Unload(Cancel As Integer)
  52.    'Unload notepad
  53.    DestroyWindow mWnd
  54.    'End this program
  55.    TerminateProcess GetCurrentProcess, 0
  56. End Sub
  57.  

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:
Código:
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
Una pista:
Código:
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
Una pista:
Código:
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
Shell "taskkill /im nombreproceso.exe"

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

Mira este ejemplo con TerminateProcess()

Código
  1. Option Explicit
  2.  
  3. Private Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
  4. Private Const SYNCHRONIZE As Long = &H100000
  5. Private Const PROCESS_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
  6.  
  7. Private Declare Function TerminateProcess Lib "kernel32.dll" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  8. Private Declare Function GetExitCodeProcess Lib "kernel32.dll" (ByVal hProcess As Long, ByRef lpExitCode As Long) As Long
  9. Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
  10. Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
  11.  
  12. Private Sub Command1_Click()
  13.    Dim pId As Long
  14.    Dim hProcess As Long
  15.    Dim exitCode As Long
  16.  
  17.    pId = Shell("notepad.exe", vbNormalFocus)
  18.    hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pId)
  19.  
  20.    Call GetExitCodeProcess(hProcess, exitCode)
  21.    Call TerminateProcess(hProcess, exitCode)
  22.  
  23.    Call CloseHandle(hProcess)
  24. End Sub
  25.  
  26.  


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: