Sabria alguien decirme como puedo saber que un proceso en
Msdos lanzado en Vb O VBA ha finalizado.
RESPONDE RUBEN VIGON
=====================
Prueba el siguiente código, haciendo algo así como:
RunTillFinished "c:\windows\command\edit.com"
MsgBox "Proceso finalizado"
Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long,ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long,ByVal dwMilliseconds As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Const NORMAL_PRIORITY_CLASS = &H20&
Public Const INFINITE = -1&
Public Sub RunTillFinished(ToRun As String, Optional CommandLine As Variant)
Dim CmdLine$, Ret&, proc As PROCESS_INFORMATION, Start As STARTUPINFO
If Not IsMissing(CommandLine) Then
CmdLine$ = ToRun & " " & CommandLine
Else
CmdLine$ = ToRun
End If
Start.cb = Len(Start)
Ret& = CreateProcessA(0&, CmdLine$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, Start, proc)
Ret& = WaitForSingleObject(proc.hProcess, INFINITE)
Ret& = CloseHandle(proc.hProcess)
End Sub
               (
geocities.com/es/ensolva/Descargas)                   (
geocities.com/es/ensolva)                   (
geocities.com/es)