delphi2007 教程

delphi2007 教程

首页 新随笔 联系 聚合 管理
  1013 Posts :: 0 Stories :: 28 Comments :: 0 Trackbacks
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;

posted on 2008-10-14 16:34 delphi2007 阅读(218) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。