bok
2012-07-19 18:45:01 UTC
Hello,
The line below of "S:=Reversestring(S)" causes a file full of "nul" to be written instead of S. How do I manipulate S and then correctly write the altered
string to n2.exe.
Thanks,
DBM
=========================================================
procedure TForm1.Button1Click(Sender: TObject);
var
readit,writeit: TFileStream;
s: string;
x:integer;
begin
readit := TFileStream.Create('n1.exe', fmOpenread);
writeit := TFileStream.Create('n2.exe', fmCreate or fmOpenWrite);
try
SetLength(s,readit.Size);
readit.Read(PChar(s)^, Length(s));
s:=reversestring(s); //<<<<<<-This line is incorrect
writeit.Write(PChar(s)^, Length(s));
finally
readit.Free;
writeit.Free;
end;
end;
The line below of "S:=Reversestring(S)" causes a file full of "nul" to be written instead of S. How do I manipulate S and then correctly write the altered
string to n2.exe.
Thanks,
DBM
=========================================================
procedure TForm1.Button1Click(Sender: TObject);
var
readit,writeit: TFileStream;
s: string;
x:integer;
begin
readit := TFileStream.Create('n1.exe', fmOpenread);
writeit := TFileStream.Create('n2.exe', fmCreate or fmOpenWrite);
try
SetLength(s,readit.Size);
readit.Read(PChar(s)^, Length(s));
s:=reversestring(s); //<<<<<<-This line is incorrect
writeit.Write(PChar(s)^, Length(s));
finally
readit.Free;
writeit.Free;
end;
end;