cs_lionel4
Messages postés129Date d'inscriptionsamedi 29 novembre 2003StatutMembreDernière intervention26 septembre 2008
-
7 févr. 2004 à 12:35
cs_labout
Messages postés1356Date d'inscriptionsamedi 8 décembre 2001StatutMembreDernière intervention23 octobre 2006
-
24 févr. 2004 à 13:01
Voila je cherche a tester la présence d'1 processus précis. J'ai vu beaucoup de code pour killer des processus ou pour les lister ttous. Moi j'aimerais tester si le processus "monprocessus " est actif. Ca doit pas etre bien compliqué ? Merci d'avance à tous.
cs_labout
Messages postés1356Date d'inscriptionsamedi 8 décembre 2001StatutMembreDernière intervention23 octobre 20068 7 févr. 2004 à 13:06
labout
Tout était dans mon Killer process
Ouvre le bloc notes
Dans une Form avec un bouton
Private Sub Command1_Click()
Dim process As String
Dim i As Integer
process = "Sans titre - Bloc-notes"
Call GetWinHandles
For i = 0 To UBound(atabwhnd)
If atabwhnd(i) = process Then
MsgBox atabwhnd(i)
End If
Next
End Sub
Dans un module
Public Declare Function EnumWindows& Lib "user32" (ByVal lpEnumFunc As Long, _
ByVal lParam As Long)
Public Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" (ByVal hwnd As Long, _
ByVal lpString As String, _
ByVal cch As Long) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public atabwhnd()
Public iWnd As Integer
Public Sub GetWinHandles()
' permet de connaitre toutes les applications en cours
Dim lonstatus As Long
Dim londummy As Long
iWnd = 0&
lonstatus = EnumWindows&(AddressOf EnumWindowsproc, ByVal iWnd)
End Sub
Function EnumWindowsproc(ByVal addhWnd As Long, ByVal optparam As Long) As Long
' extrait les proccess en cours
Dim st As String
Dim cc As Long
Dim x As Long
Dim y
Dim z As Long
Dim sclass As String
sclass = String(250, " ")
y = addhWnd
cc = 250
st = Space(250)
x = GetWindowText(addhWnd&, st, cc)
If Asc(Left(st, 1)) > 0 Then
If iWnd > 0 Then
ReDim Preserve atabwhnd(iWnd)
Else
ReDim Preserve atabwhnd(1)
iWnd = 1
End If
z = GetClassName(addhWnd&, sclass, 250)
atabwhnd(iWnd) = Left(st, x)
iWnd = iWnd + 1
End If
EnumWindowsproc = True
End Function
Le code du form peut etre transformé en fonction
Function IsProcess(process) as boolean
isprocess=false
dim i as integer
for i=0 to ubound(atabwhnd)
if atabwhnd(i)=process then
IsProcess=true
exit for
endif
next
Dans le code qui recherche
If isProcess("Sans titre - Bloc-notes") then
' code
else
' code
ebdif