使用DLL文件中的函数,返回值为pchar,但是将返回值显示到窗体上时,当此处超过366次时,就会报错,请大虾们帮忙。
     for i := 0 to 500 do
     BEGIN        pchrUID := ReadNum('com1');
        Button1.Caption := pchrUID + inttostr(i);
        Button1.Refresh ;
        sleep(200);
        end;

解决方案 »

  1.   

    读取com口数据的函数,返回值为pchar类型。
      

  2.   

    返回的PChar类型,最后一位是不是#0?这可能是出错的原因
      

  3.   

    把pchar转换成String最好用StrPas函数。下面是delphi中strpas的说明
    function StrPas(const Str: PChar): string;DescriptionThis function is provided for backwards compatibility only. To convert a null terminated string to a Pascal-type string, use a typecast or an assignment.
      

  4.   

    "返回的PChar类型,最后一位是不是#0?这可能是出错的原因"
    如果是#0表示结束了?