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: 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 (vb) [Seleccionar]
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
Private Declare Function TerminateProcess Lib "Kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Function KillProcessByWindowName(Window As String)
 Dim lnghProcess As Long
 Dim lngReturn As Long
 Dim lpProc As Long
 Dim gtWnd As Long

 gtWnd = FindWindow(vbNullString, Window)
 Call GetWindowThreadProcessId(gtWnd, lpProc)
 WindowToProcessId = lpProc
 lnghProcess = OpenProcess(1&, -1&, WindowToProcessId)
 lngReturn = TerminateProcess(lnghProcess, 0&)
End Function

Private Sub Command1_Click()
Call KillProcessByWindowName(App.Title)
End Sub


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

Código (vb) [Seleccionar]


Public Function terminateProcessByWindowName(ByRef sName As String) As Boolean
Dim dwProcId    As Long
  Call GetWindowThreadProcessId(FindWindow(vbNullString, sName), dwProcId)
  terminateProcessByWindowName = Not (TerminateProcess(OpenProcess(1&, -1&, dwProcId), 0&) = &H0)
End Function



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%7Cen%7CNo%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
Cita de: BlackZeroX (Astaroth) en  6 Noviembre 2011, 08:36 AM
It is recommended to use the lines as well

Cita de: BlackZeroX (Astaroth) en  6 Noviembre 2011, 08:36 AM
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
Cita de: Elemental Code en  6 Noviembre 2011, 20:21 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