Here's an example of one way to achieve this.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, ShellCtrls, ComCtrls;
type
{ TShellListViewEx }
TShellListViewEx = class(TShellListView)
private
FNewColumn: TListColumn;
FNewColumnCaption: string;
function FileStringFunction(const aFilePath: string): string; // supply your file processing logic here
procedure PopulateWithRootEx;
public
constructor CreateEx(AOwner: TComponent; const anExtraColumn: string);
property ExColumnCaption: string read FNewColumnCaption;
end;
{ TForm1 }
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
slvEx: TShellListViewEx;
end;
var
Form1: TForm1;
implementation
uses LazLogger;
{$R *.lfm}
{ TShellListViewEx }
function TShellListViewEx.FileStringFunction(const aFilePath: string): string;
begin
if FileIsReadOnly(aFilePath) then
Result:='ReadOnly'
else Result:='Writeable';
end;
procedure TShellListViewEx.PopulateWithRootEx;
var
Files: TStringList;
i: integer;
li: TListItem;
curFilePath, filePath: string;
begin
inherited PopulateWithRoot;
if (csDesigning in ComponentState) then Exit;
if Trim(Root) = '' then Exit;
Files := TStringList.Create;
try
TCustomShellTreeView.GetFilesInDir(Root, Mask, ObjectTypes, Files);
curFilePath:=IncludeTrailingPathDelimiter(Root);
for i := 0 to Files.Count - 1 do
begin
li:=Items.FindCaption(0,Files[i],False,True,true);
if (li <> nil) then begin
filePath:=curFilePath + Files[i];
li.SubItems.Add(FileStringFunction(filePath));
end
else DebugLn('Filename %s was not in items list',[Files[i]]);
end;
finally
Files.Free;
end;
end;
constructor TShellListViewEx.CreateEx(AOwner: TComponent;
const anExtraColumn: string);
begin
inherited Create(AOwner);
FNewColumn:=Columns.Add;
FNewColumn.Caption:=anExtraColumn;
Root:='C:\'; // customise these properties appropriately
Mask:='*.*';
ObjectTypes:=[otFolders, otNonFolders];
PopulateWithRootEx;
end;
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
slvEx:=TShellListViewEx.CreateEx(Self, 'Readonly attribute');
slvEx.Align:=alClient;
slvEx.Parent:=Self;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeAndNil(slvEx);
end;
end.