procedure TFrameTreeView.GetDirectories(Tree: TVirtualStringTree; Directory:
string; Item: PVirtualNode; IncludeFiles: Boolean);
var
SearchRec: TSearchRec;
ItemTemp: PVirtualNode;
LNode : PVirtualNode;
LData : PTreeData;
Lteststring :
string;
I: Integer;
begin
Tree.BeginUpdate;
if Directory[Length(Directory)] <> '
\'
then
Directory := Directory + '
\';
if FindFirst(Directory + '
*.*', faDirectory, SearchRec) = 0
then
begin
repeat //loop
if (SearchRec.Attr
and faDirectory = faDirectory)
and (SearchRec.
Name[1] <> '
.')
then
begin
if (SearchRec.Attr
and faDirectory > 0)
then
begin
try
if not Assigned(Item)
then
break;
LData := Tree.GetnodeData(Item);
Item := Tree.AddChild(Item);
//<------ access violation
LData := Tree.GetnodeData(Item);
LData^.FPath := Directory+SearchRec.
Name;
LData^.FFolderName := SearchRec.
Name;
LData^.FFirstFolder := false;
Tree.NodeDataSize := SizeOf(TTreeData);
Tree.ValidateNode(Item, False);
except
break;
end;
end;
ItemTemp := Item.Parent;
LData := Tree.GetnodeData(ItemTemp);
GetDirectories(Tree, Directory + SearchRec.
Name, Item, IncludeFiles);
Item := ItemTemp;
end
until FindNext(SearchRec) <> 0;
FindClose(SearchRec);
end;
Tree.EndUpdate;
end;