Controller si un programme est lancé ou non

philochon Messages postés 15 Date d'inscription mercredi 8 septembre 2004 Statut Membre Dernière intervention 27 novembre 2006 - 16 sept. 2004 à 11:43
philochon Messages postés 15 Date d'inscription mercredi 8 septembre 2004 Statut Membre Dernière intervention 27 novembre 2006 - 21 sept. 2004 à 08:47
salut,

je voudrais savoir comment déterminer si un programme est lancé sous windows ?

ex si word est lancé, ou la calculatrice et meme l'exe d'une appli que j'ai développer.

toutes les minutes on test que le programme est bien lancé sinon on le lance automatiquement

philochon

2 réponses

jrivet Messages postés 7392 Date d'inscription mercredi 23 avril 2003 Statut Membre Dernière intervention 6 avril 2012 60
16 sept. 2004 à 12:27
salut,

tiens regarde cette question deja posee sur le forum ;)

je pense qu il y a peu pres ce que tu veux.

Question : Exe deja lance

@+
-------------------------------------------------
Essai ca sinon on trouvera autre chose
-------------------------------------------------

:big)
0
philochon Messages postés 15 Date d'inscription mercredi 8 septembre 2004 Statut Membre Dernière intervention 27 novembre 2006
21 sept. 2004 à 08:47
hello,

je pense avoir trouvé avec ceci grace a ton lien ! :
(J'ai testé ca marche super)

------------------------------------------------------------------------------

'Dans un module

Dim temp As String
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim sSave As String, Ret As Long
Ret = GetWindowTextLength(hwnd)
sSave = Space(Ret)
GetWindowText hwnd, sSave, Ret + 1
If sSave <> vbNullString And IsWindowVisible(hwnd) Then temp = temp & sSave & vbCrLf
'continue enumeration
EnumWindowsProc = True
End Function
Public Function App_Ouverte()
temp = ""
EnumWindows AddressOf EnumWindowsProc, ByVal 0&
App_Ouverte = temp
End Function

'Dans la form
Dim ouverte() As String
Private Sub Form_Load()
ouverte = Split(App_Ouverte, vbCrLf)
End Sub

Private Sub Timer1_Timer()
'mise a jour de list1 selon la liste de depart des appli ouverte
List1.Clear
Dim temp() As String
Erase temp
temp = Split(App_Ouverte, vbCrLf)
Dim Existe As Boolean
Existe = False
For i = 0 To UBound(temp)

For a = 0 To UBound(ouverte)
If temp(i) ouverte(a) Then Existe True: Exit For
Next a
If Not Existe And temp(i) <> Me.Caption Then List1.AddItem temp(i)
Existe = False
Next i

End Sub

------------------------------------------------------------------------------

ce bout de prog affiche les processus lancé en temps réel grace a un timer (un peu comme le gestionnaire des taches), il ne me reste plus qu'a détecter le nom de mon application dans list1 si elle n'est pas présente alors je la démarre, je pense y arriver seul MERCI

philochon
0
Rejoignez-nous