@@Exit:
pop edi
pop esi
pop ebx
ret
@@HexChar: db '0123456789ABCDEF'
end;
使用比如:
var
Stream:TMemoryStream;
s: String;
i: integer;
begin
Stream := TMemoryStream.Create;
s := '不得闲';
i := 511;
Stream.WriteBuffer(pointer(s)^,Length(s));
ShowMessage(PointToHex(Stream.Memory,Stream.size));
Stream.free;
这样就把整个Stream都转换成16进制了.Author:
不得闲 Time: 2008-7-24 20:44
关于上面的将指针区域信息转换成16进制的函数,现在碰到一个奇怪的问题,转换是很快!
但是,为什么对转换出来的字符串进行操作则很慢呢?
procedure TForm1.Button1Click(Sender: TObject);
var
BufLen,i,dwTime: integer;
buf: array of byte;
s: string;
begin
BufLen := 16384;
SetLength(Buf, BufLen);
for i := 0 to BufLen -1 do
Buf := Byte(Random(256));
procedure TMemoStrings.SetTextStr(const Value: string);
var
NewText: string;
begin
NewText := AdjustLineBreaks(Value);
if (Length(NewText) <> Memo.GetTextLen) or (NewText <> Memo.Text) then
begin
if SendMessage(Memo.Handle, WM_SETTEXT, 0, Longint(NewText)) = 0 then
raise EInvalidOperation.Create(SInvalidMemoSize);
Memo.Perform(CM_TEXTCHANGED, 0, 0);
end;
end;