1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| procedure TForm1.SauvegardeInfoDossier();
var
FileHandle: Integer;
Indice: Integer;
iBytesRead: Integer;
StringLen: Integer;
StringVal: String;
Bmp: TBitMap;
begin
if iNbFichier < 1 then Exit;
FileHandle := FileCreate('Albbrwse.abf');
StringVal := 'Commentaire.';
StringLen := Length(StringVal);
iBytesRead := FileWrite(FileHandle, StringLen, SizeOf(StringLen));
iBytesRead := FileWrite(FileHandle, StringVal, StringLen);
iBytesRead := FileWrite(FileHandle, iNbFichier, SizeOf(iNbFichier));
for Indice := 0 to sListeFichier.Count - 1 do
begin
StringVal := sListeFichier[Indice];
StringLen := Length(StringVal);
iBytesRead := FileWrite(FileHandle, StringLen, SizeOf(StringLen));
iBytesRead := FileWrite(FileHandle, StringVal, StringLen);
// Bmp := ListeIcones[Indice];
// FileWrite(FileHandle, Bmp, SizeOf(Bmp));
end;
FileClose(FileHandle);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
iFileHandle: Integer;
iFileLength: Integer;
iBytesRead: Integer;
Buffer: PChar;
Indice, i: Integer;
StringLen: Integer;
StringVal: String;
begin
try
iFileHandle := FileOpen('Albbrwse.abf', fmOpenRead);
iFileLength := FileSeek(iFileHandle,0,2);
FileSeek(iFileHandle,0,0);
iBytesRead := FileRead(iFileHandle, StringLen, SizeOf(StringLen));
Buffer := PChar(AllocMem(StringLen + 1));
iBytesRead := FileRead(iFileHandle, Buffer, StringLen);
iBytesRead := FileRead(iFileHandle, iNbFichier, SizeOf(iNbFichier));
sListeFichier.Clear;
for Indice := 0 to iNbFichier - 1 do
begin
iBytesRead := FileRead(iFileHandle, StringLen, SizeOf(StringLen));
Buffer := PChar(AllocMem(StringLen + 1));
iBytesRead := FileRead(iFileHandle, Buffer, StringLen);
sListeFichier.Add(Buffer);
end;
finally
FileClose(iFileHandle);
FreeMem(Buffer);
end;
end; |
Partager