Je viens de retrouver un tit truc mais je ne sais pas si ça marche sous XP.
Const TH32CS_SNAPHEAPLIST = &H1 Const TH32CS_SNAPPROCESS = &H2 Const TH32CS_SNAPTHREAD = &H4 Const TH32CS_SNAPMODULE = &H8 Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE) Const TH32CS_INHERIT = &H80000000 Const MAX_PATH As Integer = 260 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long th32ParentProcessID As Long pcPriClassBase As Long dwFlags As Long szExeFile As String * MAX_PATH End Type Private Declare Function CreateToolhelp32Snapshot Lib "Kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function Process32First Lib "Kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function Process32Next Lib "Kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long) Function Detection_Process(p As String) As Integer Dim hSnapShot As Long, uProcess As PROCESSENTRY32 Dim r As Long Dim NomFichier As String Dim Cpt as integer
' Création d'une vue sur les process en cours hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&) ' Initialisation de la taille du ProcessEntry-type uProcess.dwSize = Len(uProcess) ' Retourne les infos concernant le 1er processus rencontré r = Process32First(hSnapShot, uProcess) Do While r ' Elimination des caractères null NomFichier = Split(uProcess.szExeFile, Chr(0))(0) ' Récupération du nom de fichier NomFichier = Right$(NomFichier, Len(NomFichier) - InStrRev(NomFichier, "\")) If NomFichier = p Then Cpt = Cpt + 1 End If ' Infos sur le processus suivant r = Process32Next(hSnapShot, uProcess) Loop CloseHandle hSnapShot Detection_Process = Cpt
End Function
Private Sub Form_Load()
Msgbox Detection_Process("IEXPLORE.EXE") End Sub
Cordialement
CanisLupus
|