function GetCardinal(var Buffer): Cardinal;
asm
mov eax, [eax]
end;
const CrLf: Word = $0A0D;
var hFile, Index, Size, Count, Dummy: Cardinal; lpBuffer: PChar; Found: LongBool;
begin
hFile := CreateFile('c:\250.b00', GENERIC_READ, 0, nil, OPEN_EXISTING, 0, 0);
if hFile = INVALID_HANDLE_VALUE then
begin
MessageBox(0, 'No se puede acceder al archivo!', nil, MB_ICONEXCLAMATION);
Exit;
end;
lpBuffer := MapViewOfFile(CreateFileMapping(hFile, nil, PAGE_READONLY, 0, 0, nil), FILE_MAP_READ, 0, 0, 0);
Size := GetFileSize(hFile, nil);
CloseHandle(hFile);
hFile := CreateFile('c:\FileNames.txt', GENERIC_WRITE, 0, nil, CREATE_ALWAYS, 0, 0);
Index := 0;
Found := False;
while Index < Size do
begin
if not Found and (Word(GetCardinal(lpBuffer[Index])) = $4449) then begin
Count := 1;
Inc(Index, 2);
while lpBuffer[Index + Count] in ['0'..'9'] do Inc(Count);
WriteFile(hFile, lpBuffer[Index], Count, Dummy, nil);
WriteFile(hFile, CrLf, 2, Dummy, nil);
WriteFile(hFile, CrLf, 2, Dummy, nil);
Inc(Index, Count);
Found := True; end
else
if GetCardinal(lpBuffer[Index]) = $67706A2E then begin
Count := 0;
while lpBuffer[Index - Count - 1] in ['a'..'z', 'A'..'Z', '0'..'9'] do Inc(Count);
WriteFile(hFile, lpBuffer[Index - Count], Count + 4, Dummy, nil);
WriteFile(hFile, CrLf, 2, Dummy, nil);
Inc(Index, 4);
end
else
Inc(Index);
end;
CloseHandle(hFile);
end;