07/08/2002, 13:41
|
| | Fecha de Ingreso: agosto-2002
Mensajes: 12
Antigüedad: 22 años, 3 meses Puntos: 0 | |
Re: Como llamar otros archivos desde VB 6.0 te mando el codigo para ejecutar una aplicación, y esperar a que finalice, por ejemplo un archivo BAT, lo ejecuta y espera a que termine para proseguir con la siguiente instrucción.
VARIABLES
Private 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 Integer
hStdInput As Long
hstdOutput As Long
hSrdError As Long
End Type
Private Type Process_Information
hProcess As Long
hThread As Long
dwProceessID As Long
dwThreadID As Long
End Type
Private Declare Function WaitForSingleObject Lib "Kernel32" (ByVal hHandle As Long, ByVal _
dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "Kernel32" (ByVal lpAplicationName As Long, ByVal _
lpCommandLine As String, ByVal lpProcessAttributes As Long, 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
Private Declare Function CloseHandle Lib "Kernel32" (ByVal hObject As Long) As Long
Private Const Normal_Priority_Class = &H20&
Private Const Inifile = -1&
Y esta es la rutina
' Rutina que llama a una aplicación y espera a que finalice '
Public Sub WinExec(Cmdline$)
Dim Proc As Process_Information
Dim Star As StartUpInfo
'
Star.Cb = Len(Star)
'
ret& = CreateProcessA(0&, Cmdline$, 0&, 0&, 1&, NormalPriorityClass, 0&, 0&, Star, Proc)
'
'Esperar a que la aplicación termine
'
ret& = WaitForSingleObject(Proc.hProcess, Infinite)
ret& = CloseHandle(Proc.hProcess)
End Sub |