PDA

View Full Version : [Vb6] problemi con shell sincrona.


-K2-
12-07-2004, 08:11
Salve a tutti. Sotto trovate le API e la procedura che non funziona. Praticamente lancio un file .bat che lancia una piccola utility a riga di comando per inviare dati via FTP. L'utility parte ma subito si interrompe e l'esecuzione del programma torna a Vb senza terminare correttamente l'invio dei dati. Potete aiutarmi??Se avenet bisogno di ulteriori spiegazioni ci sono. Grazie!

Global Const SW_NORMAL = 1 'const per la chiamata di EseguiApp
Global Const SW_MAXIMIZE = 3
Global Const SW_MINIMIZE = 6

Global Const NORMAL_PRIORITY_CLASS = &H20&


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 Long
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 Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long

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 OpenProcess Lib "kernel32" (ByVal _
dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long

Declare Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long

'-------------------------------------------------------------------------
--------
Sub EseguiApp(cmdLine As String, cmdWsw As Long)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ret As Long
Dim inizio As Long
Dim operatore As Long, versione As Long, risultato As Long

'Initialize the STARTUPINFO structure
start.cb = Len(start)
start.dwFlags = 1 ' STARTF_USESHOWWINDOW
start.wShowWindow = cmdWsw


' Start the shelled application:
ret& = CreateProcessA(0&, cmdLine$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)

While ret& > 0
' Wait for the shelled application to finish:
ret& = WaitForSingleObject(proc.hProcess, 500)
Sleep (100) '
Wend

ret& = CloseHandle(proc.hProcess)

End Sub

matpez
12-07-2004, 13:00
Se i problema è l'FTP, non puoi usare dei comandi direttamente da VB per uploadare roba senza passare da un file bat?

-K2-
13-07-2004, 11:10
Il problema è l'esecuzione non sincrona del file .Bat.
Non so più che fare. Aiuto

matpez
13-07-2004, 11:27
Non riesco a capire bene cosa ti serva, cioè, se ti serve uplodare roba in ftp tramite quella utility si fa direttamente da VB, come mai ti serve per forza un file batch... prova a spiegarmi meglio il tuo progetto, così magari inquadro meglio il problema :)