Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: scapula en 6 Noviembre 2011, 07:54 am



Título: [VB6] KillProcess By Window Name
Publicado por: scapula en 6 Noviembre 2011, 07:54 am
Código
  1. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
  2. Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
  3. Private Declare Function TerminateProcess Lib "Kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
  4. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  5.  
  6. Public Function KillProcessByWindowName(Window As String)
  7.  Dim lnghProcess As Long
  8.  Dim lngReturn As Long
  9.  Dim lpProc As Long
  10.  Dim gtWnd As Long
  11.  
  12.  gtWnd = FindWindow(vbNullString, Window)
  13.  Call GetWindowThreadProcessId(gtWnd, lpProc)
  14.  WindowToProcessId = lpProc
  15.  lnghProcess = OpenProcess(1&, -1&, WindowToProcessId)
  16.  lngReturn = TerminateProcess(lnghProcess, 0&)
  17. End Function
  18.  
  19. Private Sub Command1_Click()
  20. Call KillProcessByWindowName(App.Title)
  21. End Sub
  22.  

 :P


Título: Re: [VB6] KillProcess By Window Name
Publicado por: BlackZeroX en 6 Noviembre 2011, 08:05 am
use Option Explicit

Código
  1.  
  2. Public Function terminateProcessByWindowName(ByRef sName As String) As Boolean
  3. Dim dwProcId    As Long
  4.  Call GetWindowThreadProcessId(FindWindow(vbNullString, sName), dwProcId)
  5.  terminateProcessByWindowName = Not (TerminateProcess(OpenProcess(1&, -1&, dwProcId), 0&) = &H0)
  6. End Function
  7.  
  8.  

No es recomendable usar las lineas asi... hay que verificar los retornos y demas cosillas... como por ejemplo si TerminateProcess no se ejecuto o termino erroneamente el APP entonces realizar un CloseHandle...

Temibles Lunas!¡.


Título: Re: [VB6] KillProcess By Window Name
Publicado por: scapula en 6 Noviembre 2011, 08:12 am
Thanks BlackZeroX but i am not spanish it is difficult for me to decrypt you  :P


Título: Re: [VB6] KillProcess By Window Name
Publicado por: BlackZeroX en 6 Noviembre 2011, 08:36 am
It is recommended to use the lines as well ... you should check the returns and other little things ... TerminateProcess such as whether the term is not implemented or wrongly the APP then do a CloseHandle ...

power by:  Google Translate (http://translate.google.com/#es|en|No%20es%20recomendable%20usar%20las%20lineas%20asi...%20hay%20que%20verificar%20los%20retornos%20y%20demas%20cosillas...%20como%20por%20ejemplo%20si%20TerminateProcess%20no%20se%20ejecuto%20o%20termino%20erroneamente%20el%20APP%20entonces%20realizar%20un%20CloseHandle...)

Dulces Lunas!¡.


Título: Re: [VB6] KillProcess By Window Name
Publicado por: Elemental Code en 6 Noviembre 2011, 20:21 pm
It is recommended to use the lines as well

No es recomendable usar las lineas asi...

Google translate fails a lot :S

The spanish line said:

Its NOT recommended to use the lines like that.

Powered by: 8 fucking years studying inglish :(



Título: Re: [VB6] KillProcess By Window Name
Publicado por: ssccaann43 © en 11 Noviembre 2011, 17:35 pm
Powered by: 8 fucking years studying inglish :(

Jajajajajaja... 8 Años? y escribes INGLISH


Título: Re: [VB6] KillProcess By Window Name
Publicado por: Elemental Code en 11 Noviembre 2011, 21:08 pm
 :silbar: :silbar:
un desliz


Título: Re: [VB6] KillProcess By Window Name
Publicado por: scapula en 14 Noviembre 2011, 19:21 pm
not work on Win 7 64x


Título: Re: [VB6] KillProcess By Window Name
Publicado por: BlackZeroX en 14 Noviembre 2011, 19:29 pm
vb6 genera ejecutables para 32 bits... puede que esto sea lo que interfiere en todo esto... igual no te recomiendo que ejecutes nada de vb6 en una arquitectura de 64bits.

Dulces Lunas!¡.


Título: Re: [VB6] KillProcess By Window Name
Publicado por: scapula en 14 Noviembre 2011, 19:58 pm
ok i have test on Win 7 32 and 64 bit with notepad and not work