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
| { 0123456789 } // commentaire de 14 caractères
uses
Windows, SysUtils;
var
a: pansichar;
h: THandle;
n: DWORD;
i: integer;
begin
a := StrAlloc(14 + 1);
FillChar(a^, (14 + 1) * SizeOf(ansichar), #0);
h := FileOpen({$I %FILE%}, fmOpenRead); // le fichier lu sera le fichier source du programme
if h <> INVALID_HANDLE_VALUE then
begin
// lecture des 14 octets
if ReadFile(h, a^, 14, n, nil) then
WriteLn('"', StrPas(a), '"');
// effacement du tampon
FillChar(a^, 14 * SizeOf(ansichar), '.');
WriteLn('"', StrPas(a), '"');
// lecture des 14 octets un par un
SetFilePointer(h, 0, nil, FILE_BEGIN);
Write('"');
for i := 1 to 14 do
begin
if ReadFile(h, (a + Pred(i))^, 1, n, nil) then
Write((a + Pred(i))^);
end;
WriteLn('"');
end;
end. |