'获取所有进程软件名和 ID
' GetAllPID(Sof() As String,PID() As Dword,Optional ByVal c As Long
' c =0  ,Sof() 带文件夹的全部文件名 其他，只是进程名
'数组从1开始，0表示没有，
'返回是数量
#Include  Once "win\tlhelp32.bi"
Function GetAllPID(Sof() as String, PID() as DWord, ByVal c as Integer = 0) as Integer
   Dim as Integer p,i,u
   Dim Proc as PROCESSENTRY32A, hSnap as HANDLE
   ReDim Sof(0), PID(0)
   hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, Null)
   If hSnap = 0 Then Exit Function
   Proc.dwSize = SizeOf(PROCESSENTRY32A)
   p = Process32FirstA(hSnap, @Proc)
   u = 100
   ReDim Sof(u), PID(u)
   While p
      'If Proc.th32ProcessID >10 Then
      I = I + 1
      If i > u Then
         u = u + 100
         ReDim Preserve Sof(u), PID(u)
      End If
      PID(I) = Proc.th32ProcessID
      If c = 0 Then
         Sof(I) = AfxGetPathFromProcessId(pId(I))
         If Len(Sof(I)) = 0 Then Sof(I) = Proc.szExeFile
      Else
         Sof(I) = Proc.szExeFile
      End If
      
      'End If
      p = Process32NextA(hSnap, @Proc)
   Wend
   CloseHandle hSnap
   ReDim Preserve Sof(i), PID(i)
   Function = i
End Function