PWidechar 怎麼求記憶體佔用大小

來源:互聯網
上載者:User
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;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.