Following example demonstrates how to handle the OnFileFound event of dcDiskScanner or dcMultiDiskScanner component. Let's say, we have the ResultsListView: TListView which we would like to fill with the search results and ImageList: TImageList which contains the 16x16 images associated with the file types.
ListItem := ListView1.Items.Add; // adding new item {** file name}
ListItem.Caption := FileName;
{** file type}
ListItem.SubItems.Add(FileType);
{** file size} ifnot (saDirectory in FileAttributes) then if FileSize <> 0then
St := FloatToStrF(Int(FileSize / 1024 + 1), ffNumber, 18, 0) + KBStr
else
St := '0' + KBStr
else
St := '';
ListItem.SubItems.Add(St);
{** file time}
ListItem.SubItems.Add(DateTimeToStr(FileTime));
{** icon image }
ListItem.ImageIndex := SysImageIndex;
if saHidden in FileAttributes then
ListItem.Cut := True; { ghosted icon for hidden files }
St := LowerCase(ExtractFileExt(FileName));
{ adding shortcut overlay for .lnk and .url } if (St = '.lnk') or (St = '.url') then
ListItem.OverlayIndex := 1;
{ //* Use code below if you don't want to use
//* system images and set DiskScanner1.UseIcons to True
ListItem.ImageIndex := ImageList1.Count;
ImageList1.AddIcon(SmallIcon); } end;
sIU/QH/K +!