Dag GOT-ters.
Ik ben bezig met een prog aant schrijven in VB6. T gaat om een processviewer met de nodige api's uiteraard. Maar nu vroeg ik me af he.. ik post hier ff een stukje code :
Hiermee haal je alle processen in een listview, werkt opzich heel aardig. Maar met EXEname krijg ik alleen de naam van de EXE. Wat ik nu zoek.. is het hele path, waar de exe staat dus. Is er een manier om dit te zoeken via het process? Want met processinfo kan je niet veel meer als alleen de exename opzoeken.
BvD.
Edit : Sorry voor de layoutfuck
Ik ben bezig met een prog aant schrijven in VB6. T gaat om een processviewer met de nodige api's uiteraard. Maar nu vroeg ik me af he.. ik post hier ff een stukje code :
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
| Public Sub display() 'looks for process currently running
Dim hSnapshot As Long ' declare variables
Dim processInfo As PROCESSENTRY32
Dim success As Long
Dim exeName As String
Dim retval As Long
Dim itm As ListItem
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0) 'get process snapshot handle
processInfo.dwSize = Len(processInfo) 'set actual size for information
success = Process32First(hSnapshot, processInfo) 'get first process info from snapshot handle
If hSnapshot = -1 Then 'No process running
Exit Sub
End If
items2 = 0 'It is used to refresh system only when new process is added or removed
While success <> 0 'Count Total number of process currently running
items2 = items2 + 1
success = Process32Next(hSnapshot, processInfo)
Wend
retval = CloseHandle(hSnapshot) 'close handle
If items1 <> items2 Then 'If new process present or removed display new information
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0) 'same old procedure to get latest process status
processInfo.dwSize = Len(processInfo)
success = Process32First(hSnapshot, processInfo)
cnt = 1
info.ListItems.Clear
While success <> 0
exeName = Left(processInfo.szExeFile, InStr(processInfo.szExeFile, vbNullChar) - 1)
Set itm = info.ListItems.Add(cnt, , GetFileName(exeName)) 'Display result in listview
itm.Tag = exeName
itm.SubItems(1) = processInfo.th32ProcessID
itm.SubItems(2) = processInfo.th32ParentProcessID
itm.SubItems(3) = processInfo.cntThreads
itm.SubItems(4) = processInfo.cntUsage
itm.SubItems(5) = processInfo.th32ModuleID
itm.SubItems(6) = processInfo.th32DefaultHeapID
cnt = cnt + 1
processInfo.dwSize = Len(processInfo)
success = Process32Next(hSnapshot, processInfo)
Wend
retval = CloseHandle(hSnapshot)
Label3.Caption = cnt - 1 & " Process Running" 'inform user with updated information
items1 = items2 'assign new item count as old item count
End If
End Sub |
Hiermee haal je alle processen in een listview, werkt opzich heel aardig. Maar met EXEname krijg ik alleen de naam van de EXE. Wat ik nu zoek.. is het hele path, waar de exe staat dus. Is er een manier om dit te zoeken via het process? Want met processinfo kan je niet veel meer als alleen de exename opzoeken.
BvD.
Edit : Sorry voor de layoutfuck
[ Voor 4% gewijzigd door wallywally op 02-11-2004 19:47 . Reden: layoutfok ]