
Dans ce code
Code : Tout sélectionner
; Forward declarations:
Declare GetProcessList()
Structure PROCESSENTRY32
dwSize.l
cntUsage.l
th32ProcessID.l
th32DefaultHeapID.l
th32ModuleID.l
cntThreads.l
th32ParentProcessID.l
pcPriClassBase.l
dwFlags.l
szExeFile.s[#MAX_PATH]
EndStructure
#TH32CS_SNAPPROCESS = 2
OpenConsole()
GetProcessList()
Procedure GetProcessList( )
;HANDLE hProcessSnap;
;HANDLE hProcess;
;PROCESSENTRY32 pe32;
;pe32.PROCESSENTRY32
DefType.PROCESSENTRY32 pe32
;DWORD dwPriorityClass;
; Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot_(#TH32CS_SNAPPROCESS, 0)
If hProcessSnap = #INVALID_HANDLE_VALUE
PrintN("CreateToolhelp32Snapshot (of processes)")
ProcedureReturn #FALSE
EndIf
; Set the size of the Structure before using it.
pe32\dwSize = SizeOf(PROCESSENTRY32)
; Retrieve information about the first process,
; And exit If unsuccessful
If Process32First_(hProcessSnap, pe32.PROCESSENTRY32) = #FALSE
PrintN("Process32First") ; Show cause of failure
CloseHandle_(hProcessSnap) ; Must clean up the snapshot object!
ProcedureReturn #FALSE
EndIf
P32Next = 1
; Now walk the snapshot of processes, And
; display information about each process in turn
While P32Next = 1
PrintN("")
PrintN( "=====================================================" ) : Debug "====================================================="
PrintN( "PROCESS NAME: "+Str(pe32\szExeFile)) : Debug "PROCESS NAME: "+Str(pe32\szExeFile)
PrintN( "-----------------------------------------------------" ) : Debug "-----------------------------------------------------"
; Retrieve the priority class.
dwPriorityClass = 0;
;hProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #FALSE, pe32\th32ProcessID)
;If hProcess = 0
; PrintN("OpenProcess")
;Else
; dwPriorityClass = GetPriorityClass_(hProcess)
; If dwPriorityClass = 0
; PrintN("GetPriorityClass")
; CloseHandle_(hProcess)
; EndIf
;EndIf
PrintN("process ID = "+Str(pe32\th32ProcessID)) : Debug "process ID = "+Str(pe32\th32ProcessID)
PrintN("thread count = "+Str(pe32\cntThreads)) : Debug "thread count = "+Str(pe32\cntThreads)
PrintN("parent process ID = "+Str(pe32\th32ParentProcessID)) : Debug "parent process ID = "+Str(pe32\th32ParentProcessID)
PrintN("Priority Base = "+Str(pe32\pcPriClassBase)) : Debug "Priority Base = "+Str(pe32\pcPriClassBase)
If dwPriorityClass
PrintN("Priority Class = "+Str(dwPriorityClass))
EndIf
; List the modules And threads associated with this process
;ListProcessModules(pe32\th32ProcessID)
;ListProcessThreads(pe32\th32ProcessID)
P32Next = Process32Next_(hProcessSnap, pe32.PROCESSENTRY32)
Wend
CloseHandle_(hProcessSnap);
ProcedureReturn #TRUE
EndProcedure
Quelqu'un comprend le truc ?