Ver Mensaje Individual
  #4  
Antiguo 31-05-2007
Avatar de cHackAll
[cHackAll] cHackAll is offline
Baneado?
 
Registrado: oct 2006
Posts: 2.159
Reputación: 22
cHackAll Va por buen camino
Cool Solucion

Creo que te es mas util el siguiente código... use pura API porque me gusta. Para las cadenas Unicode debes contar como un caracter si, un 0, otro si otro 0, etc, etc... para aumentar el "rango" cambia agrega contenido a la func. IsLetter.

Código Delphi [-]
function IsLetter(const Char: System.Char): LongBool;
begin
 Result := Char in ['a'..'z', 'A'..'Z', '0'..'9', ' '];
end;

const CrLf: Word = $0A0D;
var hFile, Index, Size, Dummy: Cardinal; lpBuffer: PChar;
begin
 hFile := CreateFile('c:\ntldr', GENERIC_READ, 0, nil, OPEN_EXISTING, 0, 0);
 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:\ntldr.txt', GENERIC_WRITE, 0, nil, CREATE_ALWAYS, 0, 0);
 Index := 0;
 while Index < Size do
  begin
   if ((Size - Index) > 3) and
      IsLetter(lpBuffer[Index]) and
      IsLetter(lpBuffer[Index + 1]) and
      IsLetter(lpBuffer[Index + 2]) and
      IsLetter(lpBuffer[Index + 3]) then
    begin
     while (Index < Size) and IsLetter(lpBuffer[Index]) do
      begin
       WriteFile(hFile, lpBuffer[Index], 1, Dummy, nil);
       Inc(Index);
      end;
     WriteFile(hFile, CrLf, 2, Dummy, nil);
    end
   else
    Inc(Index);
  end;
 CloseHandle(hFile);
end;

Espero te sirva.
Suerte!
Responder Con Cita