![]() |
![]() ![]() ![]() |
acProcessList component.
|
property Items[Index: Integer]: TacProcess read Get; default; // read-only!
|
The Items is the run-time only property, which can be used to get an access to each instance of TacProcess object (which contains the information about the process) at particular position. Index gives the position of the TacProcess object, where 0 is the position of the first process, 1 is the position of the second process, and so on ("Count - 1" is the position of last process in the list).
|
|
Items is the default property of acProcessList component. The Items identifier can be omitted when accessing the TacProcess objects. For example, the following two lines of code are both acceptable and do the same thing:
|
FirstProcess := acProcessList1.Items[0];
|
FirstProcess := acProcessList1[0];
|
|
To determinate the number of items which currently are available in the list read Count property.
|
// Demonstrates how to retrieve the list of processes and display them in the ListView:
|
procedure TForm1.Button1Click(Sender: TObject);
|
var
|
I: Integer;
|
ListItem: TListItem;
|
begin
|
acProcessList1.Refresh; // refreshing the list of processes
|
|
ListView1.Items.BeginUpdate;
|
try
|
ListView1.Items.Clear;
|
I := acProcessList1.Count;
|
if I <> 0 then
|
for I := 0 to I - 1 do
|
begin
|
ListItem := ListView1.Items.Add;
|
ListItem.Caption := acProcessList1[I].ExeName;
|
ListItem.ImageIndex := acProcessList1[I].SystemIconIndex;
|
ListItem.SubItems.Add(acProcessList1[I].Description);
|
|
// ...optionally, let's associate the Data pointer to TacProcess object
|
// and Data pointer of Process object to ListItem
|
ListItem.Data := acProcessList1[I];
|
acProcessList1[I].Data := ListItem;
|
end;
|
finally
|
ListView1.Items.EndUpdate;
|
end;
|
end;
|
Count property.
|