elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
29 Mayo 2012, 08:31  


Tema destacado: Últimos eventos sobre seguridad/inseguridad

+  Foro de elhacker.net
|-+  Programación
| |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo, raul338)
| | |-+  [VB6] KillProcess By Window Name
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [VB6] KillProcess By Window Name  (Leído 1,253 veces)
scapula

Desconectado Desconectado

Mensajes: 10


Ver Perfil
[VB6] KillProcess By Window Name
« en: 6 Noviembre 2011, 07:54 »

Código
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


« Última modificación: 6 Noviembre 2011, 07:56 por scapula » En línea
BlackZeroX (Astaroth)
Wiki

Desconectado Desconectado

Mensajes: 2.832


I'Love...!¡.


Ver Perfil WWW
Re: [VB6] KillProcess By Window Name
« Respuesta #1 en: 6 Noviembre 2011, 08:05 »

use Option Explicit

Código
 
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!¡.


« Última modificación: 6 Noviembre 2011, 08:10 por BlackZeroX (Astaroth) » En línea

Web Principal-->[ Blog(VB6) | Host File (Public & Private) | Scan Port | (New)MyInfraPC (Descubre mi Contraseña venefi. $) ]



The Dark Shadow is my passion.
El infierno es mi Hogar, mi novia es Lilith y el metal mi
scapula

Desconectado Desconectado

Mensajes: 10


Ver Perfil
Re: [VB6] KillProcess By Window Name
« Respuesta #2 en: 6 Noviembre 2011, 08:12 »

Thanks BlackZeroX but i am not spanish it is difficult for me to decrypt you  :P
« Última modificación: 6 Noviembre 2011, 08:15 por scapula » En línea
BlackZeroX (Astaroth)
Wiki

Desconectado Desconectado

Mensajes: 2.832


I'Love...!¡.


Ver Perfil WWW
Re: [VB6] KillProcess By Window Name
« Respuesta #3 en: 6 Noviembre 2011, 08:36 »

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

Dulces Lunas!¡.
En línea

Web Principal-->[ Blog(VB6) | Host File (Public & Private) | Scan Port | (New)MyInfraPC (Descubre mi Contraseña venefi. $) ]



The Dark Shadow is my passion.
El infierno es mi Hogar, mi novia es Lilith y el metal mi
Elemental Code


Desconectado Desconectado

Mensajes: 499


Im beyond the system


Ver Perfil
Re: [VB6] KillProcess By Window Name
« Respuesta #4 en: 6 Noviembre 2011, 20:21 »

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 :(

En línea

ssccaann43 ©


Desconectado Desconectado

Mensajes: 786


¬¬


Ver Perfil
Re: [VB6] KillProcess By Window Name
« Respuesta #5 en: 11 Noviembre 2011, 17:35 »

Powered by: 8 fucking years studying inglish :(

Jajajajajaja... 8 Años? y escribes INGLISH
En línea

- Miguel Núñez
Todos tenemos derechos a ser estupidos, pero algunos abusan de ese privilegio...
"I like ^TiFa^"
Elemental Code


Desconectado Desconectado

Mensajes: 499


Im beyond the system


Ver Perfil
Re: [VB6] KillProcess By Window Name
« Respuesta #6 en: 11 Noviembre 2011, 21:08 »

 :silbar: :silbar:
un desliz
En línea

scapula

Desconectado Desconectado

Mensajes: 10


Ver Perfil
Re: [VB6] KillProcess By Window Name
« Respuesta #7 en: 14 Noviembre 2011, 19:21 »

not work on Win 7 64x
En línea
BlackZeroX (Astaroth)
Wiki

Desconectado Desconectado

Mensajes: 2.832


I'Love...!¡.


Ver Perfil WWW
Re: [VB6] KillProcess By Window Name
« Respuesta #8 en: 14 Noviembre 2011, 19:29 »

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!¡.
« Última modificación: 14 Noviembre 2011, 19:31 por BlackZeroX (Astaroth) » En línea

Web Principal-->[ Blog(VB6) | Host File (Public & Private) | Scan Port | (New)MyInfraPC (Descubre mi Contraseña venefi. $) ]



The Dark Shadow is my passion.
El infierno es mi Hogar, mi novia es Lilith y el metal mi
scapula

Desconectado Desconectado

Mensajes: 10


Ver Perfil
Re: [VB6] KillProcess By Window Name
« Respuesta #9 en: 14 Noviembre 2011, 19:58 »

ok i have test on Win 7 32 and 64 bit with notepad and not work
« Última modificación: 14 Noviembre 2011, 20:00 por scapula » En línea
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
X window
GNU/Linux
supra 1 406 Último mensaje 11 Diciembre 2003, 07:34
por craftykox
Como puedo pasar archivos de window a Linux y Linux a window
GNU/Linux
luisvzla 4 734 Último mensaje 16 Marzo 2004, 19:26
por cokeing
window me
Windows
more 3 599 Último mensaje 14 Abril 2004, 18:12
por Asno
x window en Lap
GNU/Linux
S@DMAN 1 300 Último mensaje 22 Noviembre 2005, 19:17
por el-brujo
[Perl] Funcion killprocess()
Scripting
Doddy 0 148 Último mensaje 11 Octubre 2011, 18:09
por Doddy
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines