有如下代码:
var
  L_intLen: Integer;
  L_pcrResponse: PChar;
begin
  L_pcrResponse := StrAlloc(300);
  L_intLen := 0;
  try
    ws_lenr := L_intLen;
    ws_resp := L_pcrResponse;
  finally
    StrDispose(L_pcrResponse);
  end;
end;
ws_lenr与ws_resp为两个输出参数。执行了这个过程后,出现“Invalid pointer operation”的错误,未找到出错原因。请各位帮忙,找出错误原因。

解决方案 »

  1.   

    ws_resp := L_pcrResponse;
    这里把L_pcrResponse的地址赋给ws_resp,这样一来他们指向同一个地址.
    然后在这里:
       StrDispose(L_pcrResponse);你又释放了这里的空间,所以ws_resp的引用就失效了.
      

  2.   

    如何用record实现,请写出例程。
      

  3.   

    喂 声明传递的参数为 var string ws_resp然后再
    try
        ws_lenr := L_intLen;
        ws_resp :=^L_pcrResponse;//这里改一下,我不知道你的意思是不是这样。
      finally
        StrDispose(L_pcrResponse);
      end;