Code-Beispiel
Win32_Process, Prozeßliste via WMI
Lizenz: | Erster Autor: | Letzte Bearbeitung: |
k. A. | ytwinky | 28.04.2012 |
WMI bietet 40(in Worten:vierzig) Eigenschaften pro Prozeß an. Davon sind aber nicht alle besetzt bzw. nicht alle sind interessant, aber dies muß jeder für sich selbst entscheiden. Meine persönliche Ergänzung ist die Ausgabe der Eigenschaften mit Prozeß-Nummer.Eigenschafts-Nr, wenn man von der Erstellung ansich mal absieht ;-)
Die Benutzung von WMI(Windows Management Instrumentation) schränkt den Benutzerkreis soweit ein, daß 1. Windows laufen muß und 2. WMI installiert sein muß..
Doch nun der Code:
#include once "windows.bi" 'in
#define UNICODE 'this
#include once "disphelper/disphelper.bi" 'order
#include "vbcompat.bi"
'CSName
'CommandLine
'Description
'ExecutablePath
'ExecutionState
'Handle
'HandleCount
'InstallDate
'KernelModeTime
'MaximumWorkingSetSize
'MinimumWorkingSetSize
'Name
'OSName
'OtherOperationCount
'OtherTransferCount
'PageFaults
'PageFileUsage
'ParentProcessId
'PeakPageFileUsage
'PeakVirtualSize
'PeakWorkingSetSize
'Priority
'PrivatePageCount
'ProcessId
'QuotaNonPagedPoolUsage
'QuotaPagedPoolUsage
'QuotaPeakNonPagedPoolUsage
'QuotaPeakPagedPoolUsage
'ReadOperationCount
'ReadTransferCount
'SessionId
'Status
'TerminationDate
'ThreadCount
'UserModeTime
'VirtualSize
'WindowsVersion
'WorkingSetSize
'WriteOperationCount
'WriteTransferCount
Const strComputer="." 'oder "localhost" oder Environ("ComputerName")
Const impersonate="winmgmts:{impersonationLevel=impersonate}!\\" &strComputer &"\root\cimv2"
Var strServer="localhost", SelectClass="", i=0
Dim As HRESULT hres
Dim As ZString Ptr devCSName, devCommandLine, devDescription, devExecutablePath
Dim As ZString Ptr devExecutionState, devHandle, devHandleCount, devInstallDate
Dim As ZString Ptr devKernelModeTime, devMaximumWorkingSetSize, devMinimumWorkingSetSize, devName
Dim As ZString Ptr devOSName, devOtherOperationCount, devOtherTransferCount, devPageFaults
Dim As ZString Ptr devPageFileUsage, devParentProcessId, devPeakPageFileUsage, devPeakVirtualSize
Dim As ZString Ptr devPeakWorkingSetSize, devPriority, devPrivatePageCount
Dim As ZString Ptr devProcessId, devQuotaNonPagedPoolUsage, devQuotaPagedPoolUsage, devQuotaPeakNonPagedPoolUsage
Dim As ZString Ptr devQuotaPeakPagedPoolUsage, devReadOperationCount, devReadTransferCount
Dim As ZString Ptr devSessionId, devStatus, devTerminationDate, devThreadCount
Dim As ZString Ptr devUserModeTime, devVirtualSize, devWindowsVersion
Dim As ZString Ptr devWorkingSetSize, devWriteOperationCount, devWriteTransferCount
DISPATCH_OBJ(wmiSvc)
DISPATCH_OBJ(colProcess)
dhInitialize(True)
SelectClass="Select * From Win32_Process"
Print "Aktuelle Prozesse von " &strServer &".."
'configure, whether errors should be displayed or not:
'dhToggleExceptions(TRUE) 'if desired remove the first ' ;-))
hres=dhGetObject(impersonate, NULL, @wmiSvc)
hres=dhGetValue("%o", @colProcess, wmiSvc, ".ExecQuery(%s)", SelectClass)
FOR_EACH0(objProcess, colProcess, NULL)
hres=dhGetValue("%s", @devCSName, objProcess, ".CSName")
hres=dhGetValue("%s", @devCommandLine, objProcess, ".CommandLine")
hres=dhGetValue("%s", @devDescription, objProcess, ".Description")
hres=dhGetValue("%s", @devExecutablePath, objProcess, ".ExecutablePath")
hres=dhGetValue("%s", @devExecutionState, objProcess, ".ExecutionState")
hres=dhGetValue("%s", @devHandle, objProcess, ".Handle")
hres=dhGetValue("%s", @devHandleCount, objProcess, ".HandleCount")
hres=dhGetValue("%s", @devInstallDate, objProcess, ".InstallDate")
hres=dhGetValue("%s", @devKernelModeTime, objProcess, ".KernelModeTime")
hres=dhGetValue("%s", @devMaximumWorkingSetSize, objProcess, ".MaximumWorkingSetSize")
hres=dhGetValue("%s", @devMinimumWorkingSetSize, objProcess, ".MinimumWorkingSetSize")
hres=dhGetValue("%s", @devName, objProcess, ".Name")
hres=dhGetValue("%s", @devOSName, objProcess, ".OSName")
hres=dhGetValue("%s", @devOtherOperationCount, objProcess, ".OtherOperationCount")
hres=dhGetValue("%s", @devOtherTransferCount, objProcess, ".OtherTransferCount")
hres=dhGetValue("%s", @devPageFaults, objProcess, ".PageFaults")
hres=dhGetValue("%s", @devPageFileUsage, objProcess, ".PageFileUsage")
hres=dhGetValue("%s", @devParentProcessId, objProcess, ".ParentProcessId")
hres=dhGetValue("%s", @devPeakPageFileUsage, objProcess, ".PeakPageFileUsage")
hres=dhGetValue("%s", @devPeakVirtualSize, objProcess, ".PeakVirtualSize")
hres=dhGetValue("%s", @devPeakWorkingSetSize, objProcess, ".PeakWorkingSetSize")
hres=dhGetValue("%s", @devPriority, objProcess, ".Priority")
hres=dhGetValue("%s", @devPrivatePageCount, objProcess, ".PrivatePageCount")
hres=dhGetValue("%s", @devProcessId, objProcess, ".ProcessId")
hres=dhGetValue("%s", @devQuotaNonPagedPoolUsage, objProcess, ".QuotaNonPagedPoolUsage")
hres=dhGetValue("%s", @devQuotaPagedPoolUsage, objProcess, ".QuotaPagedPoolUsage")
hres=dhGetValue("%s", @devQuotaPeakNonPagedPoolUsage, objProcess, ".QuotaPeakNonPagedPoolUsage")
hres=dhGetValue("%s", @devQuotaPeakPagedPoolUsage, objProcess, ".QuotaPeakPagedPoolUsage")
hres=dhGetValue("%s", @devReadOperationCount, objProcess, ".ReadOperationCount")
hres=dhGetValue("%s", @devReadTransferCount, objProcess, ".ReadTransferCount")
hres=dhGetValue("%s", @devSessionId, objProcess, ".SessionId")
hres=dhGetValue("%s", @devStatus, objProcess, ".Status")
hres=dhGetValue("%s", @devTerminationDate, objProcess, ".TerminationDate")
hres=dhGetValue("%s", @devThreadCount, objProcess, ".ThreadCount")
hres=dhGetValue("%s", @devUserModeTime, objProcess, ".UserModeTime")
hres=dhGetValue("%s", @devVirtualSize, objProcess, ".devVirtualSize")
hres=dhGetValue("%s", @devWindowsVersion, objProcess, ".devWindowsVersion")
hres=dhGetValue("%s", @devWorkingSetSize, objProcess, ".WorkingSetSize")
hres=dhGetValue("%s", @devWriteOperationCount, objProcess, ".WriteOperationCount")
hres=dhGetValue("%s", @devWriteTransferCount, objProcess, ".WriteTransferCount")
i+=1
Print Format(i, "0#") &".01 CSName:" &*devCSName
Print Format(i, "0#") &".02 CommandLine:" &*devCommandLine
Print Format(i, "0#") &".03 Description:" &*devDescription
Print Format(i, "0#") &".04 ExecutablePath:" &*devExecutablePath
Print Format(i, "0#") &".05 ExecutionState:" &*devExecutionState
Print Format(i, "0#") &".06 Handle:" &*devHandle
Print Format(i, "0#") &".07 HandleCount:" &*devHandleCount
Print Format(i, "0#") &".08 InstallDate:" &*devInstallDate
Print Format(i, "0#") &".09 KernelModeTime:" &*devKernelModeTime
Print Format(i, "0#") &".10 MaximumWorkingSetSize:" &*devMaximumWorkingSetSize
Print Format(i, "0#") &".11 MinimumWorkingSetSize:" &*devMinimumWorkingSetSize
Print Format(i, "0#") &".12 Name:" &*devName
Print Format(i, "0#") &".13 OSName:" &*devOSName
Print Format(i, "0#") &".14 OtherOperationCount:" &*devOtherOperationCount
Print Format(i, "0#") &".15 OtherTransferCount:" &*devOtherTransferCount
Print Format(i, "0#") &".16 PageFaults:" &*devPageFaults
Print Format(i, "0#") &".17 PageFileUsage:" &*devPageFileUsage
Print Format(i, "0#") &".18 ParentProcessId:" &*devParentProcessId
Print Format(i, "0#") &".19 PeakPageFileUsage:" &*devPeakPageFileUsage
Print Format(i, "0#") &".20 PeakVirtualSize:" &*devPeakVirtualSize
Print Format(i, "0#") &".21 PeakWorkingSetSize:" &*devPeakWorkingSetSize
Print Format(i, "0#") &".22 Priority:" &*devPriority
Print Format(i, "0#") &".23 PrivatePageCount:" &*devPrivatePageCount
Print Format(i, "0#") &".24 ProcessId:" &*devProcessId
Print Format(i, "0#") &".25 QuotaNonPagedPoolUsage:" &*devQuotaNonPagedPoolUsage
Print Format(i, "0#") &".26 QuotaPagedPoolUsage:" &*devQuotaPagedPoolUsage
Print Format(i, "0#") &".27 QuotaPeakNonPagedPoolUsage:" &*devQuotaPeakNonPagedPoolUsage
Print Format(i, "0#") &".28 QuotaPeakPagedPoolUsage:" &*devQuotaPeakPagedPoolUsage
Print Format(i, "0#") &".29 ReadOperationCount:" &*devReadOperationCount
Print Format(i, "0#") &".30 ReadTransferCount:" &*devReadTransferCount
Print Format(i, "0#") &".31 SessionId:" &*devSessionId
Print Format(i, "0#") &".32 Status:" &*devStatus
Print Format(i, "0#") &".33 TerminationDate:" &*devTerminationDate
Print Format(i, "0#") &".34 ThreadCount:" &*devThreadCount
Print Format(i, "0#") &".35 UserModeTime:" &*devUserModeTime
Print Format(i, "0#") &".36 VirtualSize:" &*devVirtualSize
Print Format(i, "0#") &".37 WindowsVersion:" &*devWindowsVersion
Print Format(i, "0#") &".38 WorkingSetSize:" &*devWorkingSetSize
Print Format(i, "0#") &".39 WriteOperationCount:" &*devWriteOperationCount
Print Format(i, "0#") &".40 WriteTransferCount:" &*devWriteTransferCount
NEXT_(objProcess)
SAFE_RELEASE(wmiSvc)
SAFE_RELEASE(colProcess)
dhUninitialize(True)
Print "Eniki..";
GetKey
Fröhliches Prozesselisten
Gruß
ytwinky
Zusätzliche Informationen und Funktionen |
- Das Code-Beispiel wurde am 28.04.2012 von ytwinky angelegt.
- Die aktuellste Version wurde am 28.04.2012 von ytwinky gespeichert.
|
|