21. august 2003 - 16:18Der er
1 kommentar og 1 løsning
adgang til system rpocesser i wk2000 med vb6
hej! jeg har brug for en stump code (sikkert API) der kan give mig info omkring system og applicasions processer for alle brugere eller en given bruger på en server.
Mit program skal bla. bruges til at chekke om der kører flere processer af samme slags samt display udvalgte processer in en log.
Hvordan får jeg adgang til disse informationer, har har fundet noget code til vb.net men nu er det altså sådan jeg skal anvende vb6.
Private Const TH32CS_SNAPPROCESS As Long = 2& Private 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 CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
Dim ListOfActiveProcess() As PROCESSENTRY32 Public Function szExeFile(ByVal Index As Long) As String szExeFile = ListOfActiveProcess(Index).szExeFile End Function
Public Function dwFlags(ByVal Index As Long) As Long dwFlags = ListOfActiveProcess(Index).dwFlags End Function
Public Function pcPriClassBase(ByVal Index As Long) As Long pcPriClassBase = ListOfActiveProcess(Index).pcPriClassBase End Function
Public Function th32ParentProcessID(ByVal Index As Long) As Long th32ParentProcessID = ListOfActiveProcess(Index).th32ParentProcessID End Function
Public Function cntThreads(ByVal Index As Long) As Long cntThreads = ListOfActiveProcess(Index).cntThreads End Function
Public Function thModuleID(ByVal Index As Long) As Long thModuleID = ListOfActiveProcess(Index).th32ModuleID End Function
Public Function th32DefaultHeapID(ByVal Index As Long) As Long th32DefaultHeapID = ListOfActiveProcess(Index).th32DefaultHeapID End Function
Public Function th32ProcessID(ByVal Index As Long) As Long th32ProcessID = ListOfActiveProcess(Index).th32ProcessID End Function
Public Function cntUsage(ByVal Index As Long) As Long cntUsage = ListOfActiveProcess(Index).cntUsage End Function
Public Function dwSize(ByVal Index As Long) As Long dwSize = ListOfActiveProcess(Index).dwSize End Function
Public Function GetActiveProcess() As Long Dim hToolhelpSnapshot As Long Dim tProcess As PROCESSENTRY32 Dim r As Long, i As Integer hToolhelpSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&) If hToolhelpSnapshot = 0 Then GetActiveProcess = 0 Exit Function End If With tProcess .dwSize = Len(tProcess) r = ProcessFirst(hToolhelpSnapshot, tProcess) ReDim Preserve ListOfActiveProcess(20) Do While r i = i + 1 If i Mod 20 = 0 Then ReDim Preserve ListOfActiveProcess(i + 20) ListOfActiveProcess(i) = tProcess r = ProcessNext(hToolhelpSnapshot, tProcess) Loop End With GetActiveProcess = i Call CloseHandle(hToolhelpSnapshot) End Function
form: Private Sub Form_Load() Dim i As Integer Dim NumOfProcess As Long
NumOfProcess = GetActiveProcess For i = 1 To NumOfProcess Debug.Print szExeFile(i) Debug.Print th32ProcessID(i) Debug.Print th32DefaultHeapID(i) Debug.Print thModuleID(i) Debug.Print cntThreads(i) Debug.Print th32ParentProcessID(i) Next
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.