- Код: Выделить всё
type PFCFileInfo = packed record
fcFileName: string;
fc_isFolder: boolean;
fcFileType: string;
fcDOfC: string;
fcDOfLW: string;
fcFileSize: Int64;
end;
type TFCFileInfo = ^PFCFileInfo;
В VST имеем 5 колонок.
При создании формы
- Код: Выделить всё
VST.NodeDataSize:= SizeOf(TFCFileInfo);
При освобождении НОДА:
- Код: Выделить всё
var Data: TFCFileInfo;
begin
Data:= Sender.GetNodeData(Node);
if Assigned(Data) then
Finalize(Data^);
Ну и GetText:
- Код: Выделить всё
var Data: TFCFileInfo;
begin
Data:= Sender.GetNodeData(Node);
if Assigned(Data) then
case Column of
0: CellText:= ChangeFileExt(ExtractFileName(Data.fcFileName), '');
1: if Data.fc_isFolder then
CellText:= '[Dir]'
else
CellText:= Data.fcFileType;
2: if Data.fc_isFolder then
CellText:= ''
else
CellText:= IntToStr(Data.fcFileSize);
3: CellText:= Data.fcDOfC;
4: CellText:= Data.fcDOfLW;
end;
Само заполнение:
- Код: Выделить всё
procedure UpdateFileViewer (const ADir: string; var VFileViewer: TVirtualStringTree);
function GetAnyFileType(const Filename: string): string;
var FileInfo: TSHFileInfo;
begin
Result:= '';
FillChar(FileInfo, sizeof(FileInfo), 0);
if (SHGetFileInfo(PChar(ExtractFileExt(Filename)), FILE_ATTRIBUTE_NORMAL, FileInfo, sizeof(FileInfo), SHGFI_TYPENAME or SHGFI_USEFILEATTRIBUTES) <> 0) then
Result:= UTF8Encode(FileInfo.szTypeName);
end;
var SR: TSearchRec;
Node: PVirtualNode;
Data: TFCFileInfo;
ST: TSYSTEMTIME;
begin
VFileViewer.Enabled:= false;
VFileViewer.BeginUpdate;
VFileViewer.Clear;
if FindFirst(IncludeTrailingBackslash(ADir) + '*.*', faAnyFile, SR) = 0 then
repeat
if not ((SR.Name = '.') or (SR.Name = '..')) then
begin
Node:= VFileViewer.AddChild(VFileViewer.RootNode);
if not (vsInitialized in Node.States) then
VFileViewer.ReinitNode(Node, false);
Node.CheckType:= ctNone;
Data:= VFileViewer.GetNodeData(Node);
Data.fcFileName:= SR.Name;
if ((SR.Attr and faDirectory) = faDirectory) then
Data.fc_isFolder:= true
else
begin
Data.fc_isFolder:= false;
Data.fcFileType:= GetAnyFileType(SR.Name);
try
FileTimeToSystemTime(SR.FindData.ftCreationTime, ST);
Data.fcDOfC:= (IntToStr(ST.Day) + '.' + IntToStr(ST.Month) + '.' + IntToStr(ST.Year) + ' ' + IntToStr(ST.Hour) + '.' + IntToStr(ST.Minute) + '.' + IntToStr(ST.Second));
except
Data.fcDOfC:= '[UNDEFINE]';
end;
try
FileTimeToSystemTime(SR.FindData.ftLastWriteTime, ST);
Data.fcDOfLW:= IntToStr(ST.Day) + '.' + IntToStr(ST.Month) + '.' + IntToStr(ST.Year) + ' ' + IntToStr(ST.Hour) + '.' + IntToStr(ST.Minute) + '.' + IntToStr(ST.Second);;
except
Data.fcDOfLW:= '[UNDEFINE]';
end;
end;
end;
until FindNext(SR) <> 0;
FindClose(SR.FindHandle);
VFileViewer.EndUpdate;
VFileViewer.Enabled:= true;
end;
При вызове процедуры выдаёт ошибку:


Причём, если закомментировать всё, что связанно с fcDOfC и fcDOfLW ( с колонками 4 и 5 VST, соответственно), то всё работает на ура. Если же придать им какие либо (даже '123') значения - ошибка.
Что это и как её лечить?