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;