Sometimes we need the program we have called from shell to continue working be completely executed. For example when you create a file and want to work on the file already created.
Para ello la mejor solución es no usar la función shell directamente. Nos crearemos nuestra propia función de lanzamiento de programas:
For this, the best solution is not to use directly the shell function. We create our own function launching programs:
Previamente definiremos estas funciones:
Previously we define these functions:
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
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400
_____________________________________________________________
Public Sub Ejecutar(ByVal Ordenes As String)
On Error GoTo 20
Dim hProceso As Long
Dim Terminado As Long
hProceso = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(Ordenes, 7))
Do
GetExitCodeProcess hProceso, Terminado
DoEvents 'Esto permite esperar sin "colgar" el programa
Loop While Terminado = STILL_ACTIVE
Exit Sub
20 MsgBox "error"
End Sub
En el ejemplo de la entrada anterior (http://carreteras-laser-escaner.blogspot.com/2015/06/solution-of-spaces-in-path-of-shell.html) Partíamos de:
In the example of the previous post (http://carreteras-laser-escaner.blogspot.com/2015/06/solution-of-spaces-in-path-of-shell.html) started from:
Dim ccc,tal as string
ccc=chr(34) ' carácter espacial comillas
tal = ccc & "C:\Ruta del programa\programa.exe" & ccc & " -a -b -c " & ccc & "parametro con espacios 1" & ccc & " " & ccc & "parametro con espacios2" & ccc
Open App.Path + "\pepa.bat" For Output As #1
Print #1, tal
Close #1
Shell App.Path + "\pepa.bat",0
Lo cambiaremos a: / We will change it to:
Dim ccc,tal as string
ccc=chr(34) ' carácter espacial comillas
tal = ccc & "C:\Ruta del programa\programa.exe" & ccc & " -a -b -c " & ccc & "parametro con espacios 1" & ccc & " " & ccc & "parametro con espacios2" & ccc
Open App.Path + "\pepa.bat" For Output As #1
Print #1, tal
Close #1
Ejecutar App.Path + "\pepa.bat"
Y ahora sí que hemos terminado con todos los problemas de espacios en blanco y sincronía.
And now we have finished with all the problems of blank spaces and sync.
Y ahora sí que hemos terminado con todos los problemas de espacios en blanco y sincronía.
And now we have finished with all the problems of blank spaces and sync.
No hay comentarios:
Publicar un comentario