I have a function declare like this :
function execProc(ProcName,InValues:PChar;out OutValues:PChar):integer;  //The "OutValues" is a out parameter.
And I call this function like this:
procedure TForm1.Button6Click(Sender: TObject);
var
 v:integer;
 s:pchar;
begin
 Memo1.Clear;
 v := execProc(pchar('PROC_TEST'),pchar('aaa'),s);
 showmessage(inttostr(v)); //mark line
 Memo1.Lines.Add(strpas(s));
end;
when i delete the mark line(showmessage(inttostr(v))),i will have a correct result display in the Memo1,but if i keep use the showmessage(), the memo1 will dispaly an error string : "Messag" ,Why? Thanks for any help!
function execProc(ProcName,InValues:PChar;out OutValues:PChar):integer;
var
  str: TStrings;
  InValue,OutValue: string;
  i,j,scount: integer;
begin
Result := -100;
i := 0;
j := 0;
str := TStringList.Create;
try
  sCount := ExtractStrings(['|'], [], InValues, str);
  with kbmMWClientStoredProc1 do
  begin
    Close;
    Params.Clear;
    StoredProcName := StrPas(ProcName);
    FieldDefs.Updated := False;
    FieldDefs.Update;
    for i := 0 to Params.Count - 1 do
    begin
      if (Params[i].ParamType = ptUnknown) or
       (Params[i].ParamType = ptInput) or
       (Params[i].ParamType = ptInputOutput) then
      begin
        inc(j);
        InValue := str[j-1];
        Params[i].Value := InValue;
      end;
    end;
    try
      ExecProc;
      for i := 0 to Params.Count - 1 do
      begin
        if  (Params[i].ParamType = ptOutput) or
       (Params[i].ParamType = ptInputOutput) then
         OutValue := OutValue + '|' + Params[i].AsString;
      end;
      OutValues := PChar(Copy(OutValue,2,Length(OutValue)-1));
      Result := 0;
    except
      on E:Exception do
      begin
        if E.Message = 'Connection lost.' then Result := -101;//服务器连接失败
        if E.Message = 'Authorization failed.' then Result := -102;//身份验证失败
        Writelog(E.Message);
      end;
    end;
  end;
finally
  str.Free;
end;
end;