您的位置:首页 > 其它

PWidechar 怎么求内存占用大小

2008-10-14 16:32 288 查看
PWidechar 怎么求内存占用大小 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiBase/html/delphi_20061217124214134.html

pc:PWidechar;

allocmem(10000);

caption:=inttostr(sizeof(pc)); =4
caption:=inttostr(length(pc)); =0
我要求出是10000怎么办:

pc:PWidechar;//--这儿定义的是一个指针类型.

const bufsize=10000;

allocmem(10000);
//这里是分配一块内存给这个指针,也就是说形成了一个指针数组.
//对于指针数组来说,它有大小只能是你自己控制.

caption:=inttostr(sizeof(pc)); =4
caption:=inttostr(length(pc)); =0
我要求出是10000怎么办://---这个大小你可以通过一个常量来定义.......

还是没解决我的问题.
这么说:我给你一个PWidechar类型的指针,里面有值,不告诉你大小,你能取出里面的全部数据吗

呵~~,
这么说:我给你一个PWidechar类型的指针,里面有值,不告诉你大小,你能取出里面的全部数据吗
1.如果是字符串,你可以查找#0(NULL)结束符....

var
//p:pwidechar;
p:pchar;
str:string;
counter:integer;
begin
getmem(p,101);
fillchar(p^,100,#48);

str:='';
counter:=0;
try
while not (p^=#0) do
begin
str:=str+inttohex(ord(p^),2);
inc(p);
inc(counter);
end;
//---p:pchar;显示100;
//---p:pWidechar;显示50;
showmessage('get char total:'+inttostr(counter));
showmessage(str);
dec(p,counter);
finally
freemem(p);
end;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: