Jag försöker skapa en process som scannar angiven dir efter mappar och gör dem till Items och där efter lägger till, ENDAST, mapparnas mp3:or som Subitems.Avancerad TreeView
Har försökt med denna kod men den uppstår ett fel när jag startar funktionen.
procedure Lese_ID3Tag(Filename:string);
var
Buffer:array[1..128] of char;
F:File;
begin
AssignFile(F, Filename);
Reset(F,1); <------------------------- den här raden hänvisas till som fel
Seek(F,FileSize(F)-128);
BlockRead(F, Buffer, SizeOf(Buffer));
CloseFile(F);
with ID3Tag do begin
ID:=copy(Buffer,1,3);
Titel:=copy(Buffer,4,30);
Artist:=copy(Buffer,34,30);
Album:=copy(Buffer,64,30);
Year:=copy(Buffer,94,4);
Comment:=copy(Buffer,98,30);
Genre:=ord(Buffer[128]);
end;
end;
procedure TForm1.GetDirectories(Tree: TTreeView; Directory: string; Item: TTreeNode; IncludeFiles: Boolean);
var
SearchRec: TSearchRec;
ItemTemp: TTreeNode;
i : integer;
i2 : string;
begin
Tree.Items.BeginUpdate;
i := -1;
if Directory[Length(Directory)] <> '\' then Directory := Directory + '\';
if FindFirst(Directory + '*.*', faDirectory, SearchRec) = 0 then
begin
repeat
if (SearchRec.Attr and faDirectory = faDirectory) and (SearchRec.Name[1] <> '.') then
begin
if (SearchRec.Attr and faDirectory > 0) then
Item := Tree.Items.AddChild(Item, SearchRec.Name);
ItemTemp := Item.Parent;
GetDirectories(Tree, Directory + SearchRec.Name, Item, IncludeFiles);
Item := ItemTemp;
end
else if IncludeFiles then
if SearchRec.Name[1] <> '.' then
Lese_ID3Tag(SearchRec.Name);
Tree.Items.AddChild(Item, i2 + IntToStr(i) + ' ' + id3tag.Titel);
i := i+1;
if i < 100 then begin
i2 := '0';
end;
if i < 10 then begin
i2 := '00';
end;
if i >= 100 then begin
i2 := '';
end;
until FindNext(SearchRec) <> 0;
FindClose(SearchRec);
end;
Tree.Items.EndUpdate;
end;