Visual Basic - COMO SABER CUANDO UNA APLICACION TERMINA

Life is soft - evento anual de software empresarial
 
Vista:

COMO SABER CUANDO UNA APLICACION TERMINA

Publicado por VLG (139 intervenciones) el 23/02/2004 12:34:19
El problema es el siguiente , en un proceso llamo a un programa mediante la instruccin SHELL , me interesaria saber como puedo controlar el final de la aplicacion ejecutada mediante el SHELL
MUCHAS GRACIAS....
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:COMO SABER CUANDO UNA APLICACION TERMINA

Publicado por VICTOR (1 intervención) el 23/02/2004 15:49:24
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400

'Esperar a que un proceso termine,
Dim hProcess As Long
Dim RetVal As Long

'capturo el process ID
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(Programa_o_Archivo, vbMaximizedFocus))
Do
'Obtengo el estado del proceso
GetExitCodeProcess hProcess, RetVal
DoEvents
Sleep 100
Loop While RetVal = STILL_ACTIVE
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:COMO SABER CUANDO UNA APLICACION TERMINA

Publicado por vlg (139 intervenciones) el 23/02/2004 19:18:36
gracias por tu respuesta , pero

el procedimiento "OpenProcess" ¿donde esta definido?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

YA ESTA SOLUCIONADO , GRACIAS

Publicado por vlg (139 intervenciones) el 23/02/2004 19:50:47
EL CODIGO COMPLETO ES EL SIGUIENTE :
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) _
As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, _
lpExitCode As Long) _
As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const STILL_ACTIVE = &H103
Private Const PROCESS_QUERY_INFORMATION = &H400
Dim hProcess As Long
Dim RetVal As Long

Public Function EjecutaAPP(ByVal Tarea As String) As Boolean
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(Tarea, 1))
Do
GetExitCodeProcess hProcess, RetVal
DoEvents: Sleep 100
Loop While RetVal = STILL_ACTIVE
If RetVal = 0 Then EjecutaAPP = True: MsgBox ("Proceso terminado")

End Function

Private Sub Command1_Click()
Call EjecutaAPP("c:\windows\NOTEPAD.EXE")
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar