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
use Option Explicit
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!¡.
Thanks BlackZeroX but i am not spanish it is difficult for me to decrypt you :P
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!¡.
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 :(
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
:silbar: :silbar:
un desliz
not work on Win 7 64x
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!¡.
ok i have test on Win 7 32 and 64 bit with notepad and not work