Public Function GetProcessPidList(ByRef PidList() As Long) As Long
Dim NextProcess As Long
Dim X As Long
Dim Length As Long
Dim Process() As SYSTEM_PROCESSES
Dim ArrProcess As SafeArray1d
Dim m_BufferLen As Long
Dim ProcessBuffer() As Byte
Erase PidList
Length = &H1000
ReDim ProcessBuffer(Length) As Byte
'boucle jusqu'a ce que le buffer "ProcessBuffer()" soit assez grand
Do While NtQuerySystemInformation(SystemProcessesAndThreadsInformation, ByVal VarPtr(ProcessBuffer(0)), Length, m_BufferLen) = STATUS_INFO_LENGTH_MISMATCH
Length = Length + &H1000
ReDim ProcessBuffer(Length)
Loop
Do
'initialisation du tableau
With ArrProcess
.cbElements = 184
.cDims = 1
.cElements = 1
.fFeatures = FADF_AUTO Or FADF_FIXEDSIZE
.lLbound = 0
.pvData = VarPtr(ProcessBuffer(NextProcess))
End With
ReDim Preserve PidList(X) As Long
'copie du tableau
CopyMemory ByVal VarPtrArray(Process), VarPtr(ArrProcess), 4
PidList(X) = Process(0).ProcessID
X = X + 1
If Process(0).NextEntryDelta = 0 Then Exit Do
'definition de l'entree du prochain process dans le tableau "ProcessBuffer()"
NextProcess = NextProcess + Process(0).NextEntryDelta
Loop
'release du tableau
With ArrProcess
.cbElements = 0
.cDims = 0
.pvData = 0
End With
GetProcessPidList = X
End Function
Seul les admins et l'auteur du code lui même peuvent modifier ce code.