Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: So 18.09.05 17:41 
Hey delphianer,

hab folgenden Code. Dieser soll nach String der aus einem
memo feld genommen wird suchen.
Allerdings findet er nie etwas obwohls trin ist.
Er soll nur von der Datei die ersten 50000 bytes durchsuchen.

Dieses gefundene wird ab da mit #00 110000bytes lang überschrieben.

Weiters wenn until erreicht wird soll er abbrechen. Sprich memo.lines.letzte zeile.
Stimmt das so?

Vielen Dank...

ausblenden volle Höhe Delphi-Quelltext
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:
var imageread : TFileStream;
r : string;
w : string;
sizeprogress, s1, s2, r1, sizer, summe1 : int64;
rand, f, i1 : integer;
mem : Pointer;

begin
w := #00;
rand := 1;
imageread := TFileStream.create(Form1.Edit1.Text, fmOpenReadWrite or fmShareDenyNone);
for f := 0 to (dvdoption.memo1.lines.count) do
begin

r := dvdoption.memo1.lines[f];
s1 := PInt64(@r[1])^;
repeat
//imageread.seek(+512, sofromcurrent);
imageread.Read(r1, length(r));
//Form1.Label1.Caption := IntToStr(imageread.position) + ' / ' + InttoStr(sizeprogress) + ' bytes';
imageread.seek(-length(r) + 1, sofromcurrent);
rand := rand + 1;
//summe1 := (sizeprogress div 100);
//Form1.Gauge1.Progress := imageread.position div summe1;

if (rand = 80) then
 begin
 Application.ProcessMessages;
 rand := 1;
 end;

if (r1 = s1) then
  begin
//  imageread.Write(w, 110000);
  showmessage(IntToStr(imageread.position));
  imageread.seek(-Length(r) - 27, sofromcurrent);
  GetMem(Mem, 2);
  try
    imageread.write(Mem^, 2);
     finally
       FreeMem(Mem);
       imageread.seek(+Length(r) + 24, sofromcurrent);
      end;
  end;
until (imageread.Position > 5000000) or (Form1.Button6.Caption = 'Stop');

end;
imageread.free;
end;


Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 19.09.05 17:09 
Moin!

Was genau willst du denn eigentlich von uns wissen? Ob der Quelltext funktioniert oder nicht, wirste ja wohl noch selbst rausfinden können. :wink:

Falls du Probleme mit der Vorgehensweise zum Suchen und Ersetzen in Dateien hast, hast du schon mal die Suchfunktion benutzt? Es gibt hier schon einige Threads zu dem Thema.

cu
Narses
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Mo 19.09.05 18:38 
Hey,

sorry das ich so komisch geschrieben hab.
Natürlich geht es nicht.

Obwohl ich was in der memo habe:
ausblenden Delphi-Quelltext
1:
r := dvdoption.memo1.lines[f];					


findet er es in der Datei nicht. Der String ist aber in der Datei laut HexEditor.
Er findet es nicht.
Entweder überspringt er es oder,,....

Sorry nochmal,,,....

Moderiert von user profile iconKlabautermann: Delphi-Tags hinzugefügt.
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Sa 24.09.05 08:44 
Hey kann es sein das das falsch ist?

ausblenden Delphi-Quelltext
1:
2:
if (r1 = s1) then   
  begin


Mir ist aufgefallen wenn ich irrgendeine große Datei durchsuche
ZB DVD Image dann springt er da ein obwohl der String nicht zu finden ist und
er übersieht den rest.

Ich hab das mit Pointer gelöst.
Werden hier überhaupt Pointer-Adresse nur verglichen oder der Inhalt?

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.