AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

find hex codes in files

Ein Thema von cdkiller · begonnen am 23. Jul 2004 · letzter Beitrag vom 24. Jul 2004
Antwort Antwort
cdkiller

Registriert seit: 23. Jul 2004
23 Beiträge
 
#1

Re: find hex codes in files

  Alt 24. Jul 2004, 12:20
ok thanks.

but this is not all. i have more problems with the function which should find these strings.

first i have convert the hex bytes into the char format whith the code at the top.

now i have also strings to search like this:

AddD 4.84

and

AddD 4.83

so my dearch function:
Delphi-Quellcode:
function FindInFile(const FileName : string;
                    SearchWord : string; MatchCase : Boolean) : Integer;
var
  fs : TFileStream;
  Buffer : array [1..10000] of Char;
  Size : Integer;
  idx : Integer;
  i : Integer;
begin
  Result := -1;
  idx := 1;
  if not MatchCase then
   SearchWord := UpperCase(SearchWord);
  fs := TFileStream.Create(FileName, fmopenreadwrite or fmsharedenynone);
  try
    Repeat
      Application.ProcessMessages;
      Size := (Fs.Size - Fs.Position);
      if Size > 10000 then Size := 10000;
      Fs.ReadBuffer(Buffer, Size);
      if not MatchCase then
      begin
        for i := 1 to Size do
          Buffer[i] := Uppercase(Buffer)[i];
      end;
      for i := 1 to Size do
      begin
        if (Buffer[i] = SearchWord[idx]) then
          Inc(idx)
        else
          idx := 1;
        if (idx = Length(SearchWord)) then
        begin
          Result := (fs.Position - Size) + i - idx + 1;
          Exit;
        end;
      end;
    until fs.Position >= fs.Size;
  finally
   fs.Free;
  end;
end;
when i start the search it should first search the 4.84 instances and when it doesn't exists it should search after 4.83. The problem is, that the function stop if they had found the 4 of 4.84 or 4.83 and they they things that is 4.84 and they do not search after 4.83

what is the problem in my code ? it must detect exactly the 4.84 or 4.83.

thanks
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz