procedure TForm1.Button1Click(Sender: TObject); var s : string; tmpstr:pchar; begin GetMem(tmpstr, 120000); StrPCopy(tmpStr, PChar(Edit1.Text)); s := StrPas(tmpstr); ////////////// ShowMessage(s); FreeMem(tmpstr);end;
Delphi string default length is 2GB
var s: string; p: pchar; begin
... s := strpas(p);//or s := pchar(p);
Delphi string default length is 2GB
谢谢高手指点,我的pchar变量保存的是二进制流数据,是从数据库取出来的图片的二进制流数据,我用strpas和pchar函数试了,数据是多了,但还是不完整。我把这个pchar数据直接保存在流里,保存的数据却还原不成图片。我是这样做的: strTmp:pchar; BlobStream:TmemoryStream;if not assigned(BlobStream) then BlobStream := TMemoryStream.Create; BlobStream.SetSize(374); BlobStream.Position:=0; BlobStream.Write(strTmp,374);//图片的长度是374,为调试程序在此写死 BlobStream.SaveToFile('E:\tmp\fist.bmp');
var
s : string;
tmpstr:pchar;
begin
GetMem(tmpstr, 120000);
StrPCopy(tmpStr, PChar(Edit1.Text)); s := StrPas(tmpstr); //////////////
ShowMessage(s);
FreeMem(tmpstr);end;
p: pchar;
begin
...
s := strpas(p);//or
s := pchar(p);
strTmp:pchar;
BlobStream:TmemoryStream;if not assigned(BlobStream) then
BlobStream := TMemoryStream.Create;
BlobStream.SetSize(374);
BlobStream.Position:=0;
BlobStream.Write(strTmp,374);//图片的长度是374,为调试程序在此写死
BlobStream.SaveToFile('E:\tmp\fist.bmp');