ATTENDRE L'OUVERTURE D'UN PROGRAMME POUR CONTINUER
Robert
-
8 nov. 2000 à 11:13
cs_Loneloup
Messages postés9Date d'inscriptionmardi 25 février 2003StatutMembreDernière intervention 1 février 2008
-
3 avril 2003 à 11:42
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.
cs_Loneloup
Messages postés9Date d'inscriptionmardi 25 février 2003StatutMembreDernière intervention 1 février 2008 3 avril 2003 à 11:42
J ai trouve ca sur le msdn :
Dans un module on pose ca
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
Global Const NORMAL_PRIORITY_CLASS = &H20&
Global Const INFINITE = -1&
Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean
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
Public Sub ExecuteAndWait(cmdline$)
Dim NameOfProc As PROCESS_INFORMATION
Dim NameStart As STARTUPINFO
Dim X As Long
NameStart.cb = Len(NameStart)
X = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, _
0&, 0&, NameStart, NameOfProc)
X = WaitForSingleObject(NameOfProc.hProcess, INFINITE)
X = CloseHandle(NameOfProc.hProcess)
End Sub
et sur le bouton click ca :
AppToLaunch = App.Path & " oto.exe"
Call ExecuteAndWait(AppToLaunch)
MsgBox "Fini",vbexclamation
Resultat : au clique sur le click du bouton un prog se lance, l utilisateur ne peut pas en sortir jusqu a la fin de son execution et le programme reprend son execution et affiche "Fini"
pokbizou
Messages postés13Date d'inscriptionlundi 6 mai 2002StatutMembreDernière intervention13 novembre 2003 6 mai 2002 à 14:47
Je lance 2 progs dans 2 fenêtre MsDos différents et je voudrais que la première soit totalement éxécuter avant de passer à la deuxième. Mais là avec ce programme, ben tout s'arrête dès la première fenêtre ! Help ! Merci ...
Je n'ai pas vérifier, mais je crois que ce code ne marche que dans le cas d'un programme qui possèderait une fenêtre principale et ce que l'on utilise iswindow ou iswindowenabled. Donc ce code ne serait pas LA solution ultime.
Pour que le code marche, l'API est en fait Iswindows cela devient donc:Declare Function IsWindow Lib "user32" Alias "IsWindow" ( ByVal hwnd As Long) As Long
Puis
Retour = Shell("calc.exe",1)
Do While IsWindow(Retour)=0
Loop
Je n'arrive pas à faire tourner ces quelques lignes de code.
L'ouverture du programme appelé s'effectue normalement, mais le programme Vb plante à l'appel de la fonction.
3 avril 2003 à 11:42
Dans un module on pose ca
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
Global Const NORMAL_PRIORITY_CLASS = &H20&
Global Const INFINITE = -1&
Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean
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
Public Sub ExecuteAndWait(cmdline$)
Dim NameOfProc As PROCESS_INFORMATION
Dim NameStart As STARTUPINFO
Dim X As Long
NameStart.cb = Len(NameStart)
X = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, _
0&, 0&, NameStart, NameOfProc)
X = WaitForSingleObject(NameOfProc.hProcess, INFINITE)
X = CloseHandle(NameOfProc.hProcess)
End Sub
et sur le bouton click ca :
AppToLaunch = App.Path & " oto.exe"
Call ExecuteAndWait(AppToLaunch)
MsgBox "Fini",vbexclamation
Resultat : au clique sur le click du bouton un prog se lance, l utilisateur ne peut pas en sortir jusqu a la fin de son execution et le programme reprend son execution et affiche "Fini"
6 mai 2002 à 14:47
Une solution??
22 juin 2001 à 04:25
25 avril 2001 à 17:25
28 mars 2001 à 12:59
Puis
Retour = Shell("calc.exe",1)
Do While IsWindow(Retour)=0
Loop
17 mars 2001 à 15:35
8 nov. 2000 à 11:13
L'ouverture du programme appelé s'effectue normalement, mais le programme Vb plante à l'appel de la fonction.