monjal26
Messages postés45Date d'inscriptionlundi 5 avril 2004StatutMembreDernière intervention21 septembre 2006
-
20 avril 2004 à 14:06
florantanplan
Messages postés76Date d'inscriptionmardi 11 février 2003StatutMembreDernière intervention 8 septembre 2006
-
20 avril 2004 à 14:47
bonjour,
est il possible de savoir quand,une application que l'on a lancé depuis excel avec la commande shell,se termine?
car il y a bien des truc en vb6 mais sous vba c'est pas pareil
merci a tous
florantanplan
Messages postés76Date d'inscriptionmardi 11 février 2003StatutMembreDernière intervention 8 septembre 2006 20 avril 2004 à 14:46
Il faut utiliser ces trois api:
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
Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
lngOWCHandle=Shell("c:\application.exe",vbNormalFocus)
'La tu lances ton exe et tu récupère son handle
'On attend la fin de l'exécution de l'appli
pHandle = OpenProcess(SYNCHRONIZE, False, lngOWCHandle)
ret = WaitForSingleObject(pHandle, INFINITE)
ret = CloseHandle(pHandle)
'La ton process est terminé.
Si tu veux plus d'explication sur le fonctionnement de ces api: www.allapi.net.