Einzelnen Beitrag anzeigen

Benutzerbild von implementation
implementation

Registriert seit: 5. Mai 2008
940 Beiträge
 
FreePascal / Lazarus
 
#3

AW: Conversion from Cpp to Delphi

  Alt 27. Dez 2011, 15:32
is that correct ?
Not at all:

Delphi-Quellcode:
function StrSearch(mem: pbyte;text: pchar; size: DWORD):Boolean;
var
  pchL: pbyte;
  offset: DWORD;
  length: DWORD;
  iMax: integer;
begin
  pchL := mem;
  offset := DWORD(pchL);
  length := offset + size;
  iMax := lstrlen(text);
  while offset < length do
  begin
    if StrLIComp(PChar(pchL),PChar(text),iMax)=0 then
    begin
      result:= true; // Here you set Result := True
      Break; // .. and then jump out of the loop ...
    end;
    inc(offset);
    inc(pchL);
  end;
  // ... to here!
  result:= false; // and set Result := False
end;
So your function will always return false.
Replace "break" by "exit" and it should work.
  Mit Zitat antworten Zitat