|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Oct 2001
Messaggi: 57
|
[VB] aiuto per Shell
Salve,
un aiuto per l'esecuzione di programmi passati con Shell: Il mio programma fa questo: Private Sub Command4_Click() Dim GoEye As String Dim GoEye2 As String GoEye = App.Path & "\ISO.exe """ & parpath.Text Shell GoEye, vbNormalFocus GoEye2 = App.Path & "\ISO.exe """ & parpath2.Text Shell GoEye2, vbNormalFocus End Sub Quindi il tasto command mi attiva il programma ISO.exe 2 volte passandogli parametri diversi. Il problema è che premendo poi il tasto partono contemporaneamente, io invece vorrei che il secondo partisse una volta terminato il primo. (senza dover sfruttare due command). Esiste un comando opportuno? Grazie in anticipo. |
|
|
|
|
|
#2 |
|
Bannato
Iscritto dal: Jan 2001
Messaggi: 1976
|
Esiste una chiamata API che puoi usare al posto di Shell allo stesso modo:
copia il codice seguente in un modulo (a parte i commenti sono 20 righe di codice). La subroutine EseguiFOR(NomeApp) esegue l'applicazione NomeApp con eventuali parametri di comando e ne attende la conclusione (per un tempo a piacere, infinito con i set correnti). Codice:
Const SYNCHRONIZE = &H100000
Const INFINITE = &HFFFF 'Wait forever
Const WAIT_OBJECT_0 = 0 'The state of the specified object is signaled
Const WAIT_TIMEOUT = &H102 'The time-out interval elapsed & the object’s state
'is nonsignaled.
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Sub EseguiFOR(NomeApp)
'Copy the following code to the command button's Click event:
' The WaitForSingleObject function returns when one of the following occurs:
' - The specified object is in the signaled state.
' - The time-out interval elapses.
'
' The dwMilliseconds parameter specifies the time-out interval, in milliseconds.
' The function returns if the interval elapses, even if the object’s state is
' nonsignaled. If dwMilliseconds is zero, the function tests the object’s state
' and returns immediately. If dwMilliseconds is INFINITE, the function’s time-out
' interval never elapses.
'
' This example waits an INFINITE amount of time for the process to end. As a
' result this process will be frozen until the shelled process terminates. The
' down side is that if the shelled process hangs, so will this one.
'
' A better approach is to wait a specific amount of time. Once the time-out
' interval expires, test the return value. If it is WAIT_TIMEOUT, the process
' is still not signaled. Then you can either wait again or continue with your
' processing.
'
' DOS Applications:
' Waiting for a DOS application is tricky because the DOS window never goes
' away when the application is done. To get around this, prefix the app that
' you are shelling to with "command.com /c".
'
' For example: lPid = Shell("command.com /c " & txtApp.Text, vbNormalFocus)
'
' To get the return code from the DOS app, see the attached text file.
Dim lPid As Long
Dim lHnd As Long
Dim lRet As Long
If Trim$(NomeApp) = "" Then Exit Sub
lPid = Shell(NomeApp, vbNormalFocus)
If lPid <> 0 Then
'Get a handle to the shelled process.
lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)
'If successful, wait for the application to end and close the handle.
If lHnd <> 0 Then
lRet = WaitForSingleObject(lHnd, INFINITE)
CloseHandle (lHnd)
End If
'MsgBox "Just terminated.", vbInformation, "Shelled Application"
End If
End Sub
|
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Oct 2001
Messaggi: 57
|
Re
grazie mille, mi sarà sicuramente molto utile!
|
|
|
|
|
|
#4 |
|
Bannato
Iscritto dal: Jan 2001
Messaggi: 1976
|
ti sarà o ti è ?
no perchè è la terza volta che posto questo frammento e ancora non ho capito se:
Grazie. |
|
|
|
|
|
#5 |
|
Member
Iscritto dal: Oct 2001
Messaggi: 57
|
Re
Ma che dire... sicuramente io, come dici tu, non ci capisco un ca++o di VB.. dato che ci sto entrando ora...
Ho usato il futuro in quanto, enll'esempio da me fatto ripetevo il programma due volte passandogli parametri diversi, nel frattempo che nessuno mi rispondeva qui sul forum, ho ricompilato l'exe da C++ modificandolo e mettendoci sopra un main che fa il ciclo due volte con paramteri diversi. Ho detto mi sarà perchè alla mia GUi dovrò aggiungere altri moduli sempre exe, quindi il problema si sarebbe ripetuto. |
|
|
|
|
|
#6 |
|
Bannato
Iscritto dal: Jan 2001
Messaggi: 1976
|
come dice Lui: "nulla ad personam"
Ciao P.S. comunque non capire un ca++o di VB non è grave, il problema è non capire un ca++o di FCA |
|
|
|
|
|
#7 |
|
Member
Iscritto dal: Oct 2001
Messaggi: 57
|
Re
Ti immagini.. mica mi offendo per così poco....
[PS: per farti perdonare tuttavia potresti dove subire i miei post in futuro se avrò problemi... Cmq, ho testato su un MsgBox in seguito alla Shell, ed usando quel modulo effettivamente il messaggio appare solo dopo la fine dell'esecuzione dell'exe. Non capisco dove si possa trovare difficoltà nel fare un copia-incolla.... Grazie ed alla prossima. |
|
|
|
|
|
#8 | |
|
Bannato
Iscritto dal: Jan 2001
Messaggi: 1976
|
Re: Re
Quote:
allora comincio io: al volo: meglio il samsung SGH A400 o l'eriksson T66 grazie |
|
|
|
|
|
|
#9 |
|
Member
Iscritto dal: Oct 2001
Messaggi: 57
|
HEY!!
Ho detto che sono TLC (in fase di tesi... fai prima a chidere al venditore.... Ciap! |
|
|
|
|
|
#10 |
|
Bannato
Iscritto dal: Jan 2001
Messaggi: 1976
|
ah scusa ...
allora, per la propagazione, meglio pelosa o depilata ? |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 18:29.



















