|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jul 2001
Messaggi: 367
|
Gestione programmi multipli
Un saluto x tutti;
Avrei da sottoporvi la seguente domanda: In VB richiamo da un files eseguibile un altro eseguibile, passandogli un parametro nella riga di comando. Fin quì tutto ok. Siccome però L'exe principale deve rimanere aperto di sotto a quello chiamato, non riesco a lasciarlo bloccato fin quando non ci si finisce di lavorare sul secondario per poi tornare a quello principale. Se all'atto della chiamata metto nel files chiamate il comando enabled=false tutto ok, visto che la pagina rimane bloccata di sotto, però quando chiudo il programma secondario, come faccio (diciamo) a ridare la proprietà enabled=true per sbloccare il form???? Mille grazie a chi possa aiutarmi... Carmen |
|
|
|
|
|
#2 |
|
Member
Iscritto dal: Sep 2001
Messaggi: 181
|
scusa ma..nn ci ho capito molto...potresti essere + chiara??
fammi capire unpo' come è realizz sta cosa...hai una form principale dove...puoi chiamare vari eseguibili e...cosa è che non va??.....no no nn ho capito |
|
|
|
|
|
#3 |
|
Bannato
Iscritto dal: Jan 2001
Messaggi: 1976
|
Metti il codice seguente in un Modulo
La subroutine EseguiFOR(NomeApp) funziona come il comando Shell con la differenza che attende (per un certo tempo, con i set dell'esempio per un tempo infinito) l'esecuzione completa dell'applicazione secondaria prima di proseguire con l'istruzione successiva. Ciao 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
|
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Jul 2001
Messaggi: 367
|
Mamma Mia!!! comunque grazie del codice... Cercherò di studiarmelo con attenzione...
Grazie.........!!!! Carmen |
|
|
|
|
|
#5 |
|
Bannato
Iscritto dal: Jan 2001
Messaggi: 1976
|
Non lo devi studiare ... lo devi usare !
Come al solito ... |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 22:51.



















