Menu
Home
Products
  WmiSet Components
    Release History
    TWmiQuery
    TWmiOs
    TWmiRegistry
    TWmiConnection
    TWmiStorageInfo
    TWmiDiskQuotaControl
    TWmiSystemEvents
    TWmiMethod
    TWmiPerformanceMonitor
  NTSet components
  "How to" zone
  Shareware
  Full version
  Archive
  NTSet
  WmiSet
Contact us
Advanced search
Site map

Quick search

Advanced search

New version notify
e-mail address: Subscribe Unsubscribe
Privacy statement
TWmiProcessControl component

TWmiProcessControl is a part of WmiSet Component Collection for Delphi, C++Builder. This VCL component controls the processes running on a local or remote computers. It can start, terminate processes, as well as return a lot of info about them. Under Windows XP, Windows 2003 Operating Systems the component is capable of tracing processes, that is the component will fire an event when a new process starts, or existing process terminates. This is typical scenario of using the component:
  • Connect to the destination computer;
  • Enumerate running processes;
  • For each process do required actions.
The following code demonstrates this scenario. The code assumes that the component was dropped on the form at design time.
procedure TForm1.PerformTask;
var
  i: integer;
  vProcess: TWmiProcess;
begin
  with WmiProcessControl1 do
  begin
    Credentials.UserName := 'DOMAIN\Administrator';
    Credentials.Password := 'mypassword';
    // computer name will also work
    MachineName := '10.8.26.76'; 
    Active := true;
    for i := 0 to Processes.Count - 1 do
    begin
      vProcess := Processes[i];
      // do required processing here
    end;
  end;
end;
        		
The first two lines are required only if current user does not have access to destination computer. The third line may be omitted when connecting to local computer. Once the instance of TWmiProcess is obtained, it may be used to terminate process or to read its properties. The following properties are supported, though some of them may return empty values under different Window OSes:

Property Description
Handle Returns process identifier.
Caption Returns short description of the process.
CreationDate Returns the date and time when the process was created.
Description Returns description of the process.
ExecutablePath Returns path to an executable file of the process.
HandleCount Returns number of handles currently open by a process.
KernelModeTime Returns the time that the process has executed in kernel mode.
MaxWorkingSetSize Returns maximum size of process' working set.
MinWorkingSetSize Returns minimum size of process' working set.
Name Returns name of the process.
OtherOperationCount Returns number of other I/O operations performed.
OtherTransferCount Returns amount of data transferred.
PageFaults Returns number of page faults generated by the process.
PageFileUsage Returns amount of page file space used by the process.
ParentProcessId Returns identifier of the process that created this process.
PeakPageFileUsage Returns peak usage of space in a page file.
PeakVirtualSize Returns peak usage of virtual memory for the process.
PeakWorkingSetSize Returns peak size of process working size.
Priority Returns scheduling priority of the process within the operating system.
PrivatePageCount Returns number of private memory pages.
ProcessId Returns global process identifier that can be used to identify a process.
QuotaNonPagePoolUsage Returns quota amount of non-paged pool usage for the process.
QuotaPagePoolUsage Returns quota amount of paged pool usage for the process.
QuotaPeakNonPagePoolUsage Returns peak quota amount of non-paged pool usage for the process.
QuotaPeakPagePoolUsage Returns peak quota amount of paged pool usage for the process.
ReadOperationCount Returns number of read operations performed by the process.
ReadTransferCount Returns amount of data read by the process.
SessionId Returns identifier of the session that the process belongs to.
ThreadCount Returns number of active threads in this process.
UserModeTime Returns time that the process has executed in user mode.
WorkingSetSize Returns size of working set for the process.
WriteOperationCount Returns number of write operations performed.
WriteTransferCount Returns amount of data written by the process.

The WmiSet collection comes with example that demonstrates how to use TWmiProcessControl component. The example implements task manager that is capable of controlling and tracking processes on a local or remote host. Click here to download the compiled executable.