Bueno el titulo lo dice todo, necesito algun codigo que mate x proceso al ser ejecutado el programa ;)
Gracias :)
y mi respuesta lo dice todo, prográmatelo. de nada ;)
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.
Cita de: 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.
Lympex? LOL
Lympex lo sabe, no es el kien esta pedindo ayuda :P
@
LympexCitary mi respuesta lo dice todo, prográmatelo. de nada ;)
que clase de respuesta es esa de parte de un colaborador????
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Const GW_HWNDNEXT = 2
Dim mWnd As Long
Function InstanceToWnd(ByVal target_pid As Long) As Long
Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
'Find the first window
test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
Do While test_hwnd <> 0
'Check if the window isn't a child
If GetParent(test_hwnd) = 0 Then
'Get the window's thread
test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
If test_pid = target_pid Then
InstanceToWnd = test_hwnd
Exit Do
End If
End If
'retrieve the next window
test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
Loop
End Function
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim Pid As Long
'Lock the window update
LockWindowUpdate GetDesktopWindow
'Execute notepad.Exe
Pid = Shell("c:\windows\notepad.exe", vbNormalFocus)
If Pid = 0 Then MsgBox "Error starting the app"
'retrieve the handle of the window
mWnd = InstanceToWnd(Pid)
'Set the notepad's parent
SetParent mWnd, Me.hwnd
'Put the focus on notepad
Putfocus mWnd
'Unlock windowupdate
LockWindowUpdate False
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Unload notepad
DestroyWindow mWnd
'End this program
TerminateProcess GetCurrentProcess, 0
End Sub
lo saque del api-guide... te recomiendo que lo bajes
Saludos
si copie el nick mal,pero era ErMoja :P
Una pista:
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
Cita de: Krackwar en 11 Junio 2008, 23:21 PM
Una pista:
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???
Cita de: skullsp en 11 Junio 2008, 23:29 PM
Cita de: Krackwar en 11 Junio 2008, 23:21 PM
Una pista:
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 .
Shell "taskkill /im nombreproceso.exe"
Cita de: astaroth_15 en 27 Junio 2008, 10:09 AM
Shell "taskkill /im nombreproceso.exe"
Ok eso funciona pero lo correcto es que lo haga en VB.
Mira este ejemplo con TerminateProcess()
Option Explicit
Private Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
Private Const SYNCHRONIZE As Long = &H100000
Private Const PROCESS_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
Private Declare Function TerminateProcess Lib "kernel32.dll" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32.dll" (ByVal hProcess As Long, ByRef lpExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Private Sub Command1_Click()
Dim pId As Long
Dim hProcess As Long
Dim exitCode As Long
pId = Shell("notepad.exe", vbNormalFocus)
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pId)
Call GetExitCodeProcess(hProcess, exitCode)
Call TerminateProcess(hProcess, exitCode)
Call CloseHandle(hProcess)
End Sub
hombre nader, perdido!!! ya no te veo por msn, jeje esa forma es la PRO :¬¬ :laugh: