你要是装有BusinessSkinForm的话,可以看一下它里面TbsSkinFileListView控件中对应的bsSkinShellCtrls单元中的方法(1073行)
function TbsSkinFileListView.AddFile(FileMask: String;
Attr: DWord): Boolean;
写得很详细,没装的话,也可以去下一个来看看的
function TbsSkinFileListView.AddFile(FileMask: String;
Attr: DWord): Boolean;
var
ShInfo: TSHFileInfo;
attributes: String;
FDate, FName, FileName: String;
FSize: Integer;
FI: TSearchRec;
function AttrStr(Attr: integer): String;
begin
Result:='';
if (FILE_ATTRIBUTE_DIRECTORY and Attr)>0 then
Result:=Result+'';
if (FILE_ATTRIBUTE_ARCHIVE and Attr)>0 then
Result:=Result+'A';
if (FILE_ATTRIBUTE_READONLY and Attr)>0 then
Result:=Result+'R';
if (FILE_ATTRIBUTE_HIDDEN and Attr)>0 then
Result:=Result+'H';
if (FILE_ATTRIBUTE_SYSTEM and Attr)>0 then
Result:=Result+'S';
end;
begin
Result := False;
if not SetCurrentDir(FDirectory) then
exit;
if FindFirst(FileMask,faAnyFile,FI)=0 then
try
repeat
if ((Attr and FILE_ATTRIBUTE_DIRECTORY)=(FI.Attr and FILE_ATTRIBUTE_DIRECTORY)){ and
((Attr and FILE_ATTRIBUTE_READONLY)>=(FI.Attr and FILE_ATTRIBUTE_READONLY)) and
((Attr and FILE_ATTRIBUTE_HIDDEN)>=(FI.Attr and FILE_ATTRIBUTE_HIDDEN)) and
((Attr and FILE_ATTRIBUTE_SYSTEM)>=(FI.Attr and FILE_ATTRIBUTE_SYSTEM))} then
begin
CurPath:=IncludeTrailingBackslash(FDirectory);
FName:=FI.Name;
FileName:=IncludeTrailingBackslash(FDirectory)+FName;
if (FName='.') or (FName='..') then
continue;
SHGetFileInfo(PChar(FileName),0,ShInfo,SizeOf(ShInfo),SHGFI_TYPENAME or SHGFI_SYSICONINDEX or SHGFI_DISPLAYNAME);
FSize:=FI.Size;
FDate:=DateTimeToStr(FileDateToDateTime(FI.Time));
Attributes:=AttrStr(FI.Attr);
with Items.Adddo
begin
Caption:=FName;
if SmallImages<>nil then
ImageIndex:=ShInfo.iIcon;
if (FI.Attr and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY then
SubItems.Add(' ')
else
SubItems.Add(Trim(IntToStr(FSize)));
SubItems.Add((ShInfo.szTypeName));
SubItems.Add(FDate);
SubItems.Add(attributes);
SubItems.Add(FileName);
if (FI.Attr and FILE_ATTRIBUTE_DIRECTORY)=FILE_ATTRIBUTE_DIRECTORY then
SubItems.Add('dir')
else
SubItems.Add('file');
end;
FDirectorySize:=FDirectorySize+FSize;
Result:=True;
end;
until FindNext(FI)<>0;
finally
FindClose(FI);
end;
end;