-----------------
C++头文件中的声明
-----------------
typedef char TPTTCIVarChar16[17];
typedef char TPTTCIDate[9];struct CPTTCISecInfoField  
{
  TPTTCIVarChar16 m_strSecID;
  TPTTCIVarChar16 m_strSecType;
  TPTTCIVarChar16 m_strExch;
};
struct CPTTCIPosInfoField : public CPTTCISecInfoField
{
TPTTCIVarChar16 m_strPlanID;
TPTTCIVarChar16 m_strFundID;
TPTTCIDate m_strBookDate;
TPTTCIVarChar16 m_strLSType;
TPTTCIVarChar16 m_strSAType;
TPTTCIVolumeType m_nInitHoldVol;
TPTTCIPriceType m_fInitCostPrc;
TPTTCIMoneyType m_fInitSumRlzPL;
TPTTCIMoneyType m_fInitSumFee; 
TPTTCIVolumeType m_nInitSumOpnVol;
TPTTCIVolumeType m_nHoldVol;
TPTTCIPriceType m_fCostPrc;
TPTTCIMoneyType m_fSumRlzPL;
TPTTCIMoneyType m_fSumFee;
TPTTCIMoneyType m_fFltPL;
           ......
  };CPTTCIRspInfoField * _stdcall TCI_ReqQryPlanInst(void *,const TPTTCIVarChar16 strInstID,const TPTTCIDate strBookDate,CPTTCIInstInfoField& InstructData) ;CPTTCIRspInfoField * _stdcall TCI_ReqDownPlanInst(void *,const TPTTCIVarChar16 strPlanID,const TPTTCIDate strBookDate, CPTTCIInstInfoField * &pInfoField,int & RealSize);请问这两句怎么翻译成Delphi?我是这样翻的
  TPTTCIVarChar16=array[0..16] of Char;
  TPTTCIDate=array[0..8] of Char;  CPTTCISecInfoField = record
    m_strSecID : TPTTCIVarChar16;  
    m_strSecType : TPTTCIVarChar16;
    m_strExch : TPTTCIVarChar16;   
  end;
TCPTTCIPosInfoField = record
    m_secifo             : CPTTCISecInfoField;
    m_strPlanID          : TPTTCIVarChar16  ;
    m_strFundID          : TPTTCIVarChar16  ;  
    m_strBookDate        : TPTTCIDate       ;   
    m_strLSType          : TPTTCIVarChar16  ; 
    m_strSAType          : TPTTCIVarChar16  ; 
    m_nInitHoldVol       : TPTTCIVolumeType ; 
    m_fInitCostPrc       : TPTTCIPriceType ;
    ......
 end;
  CPTTCIPosInfoField = array of TCPTTCIPosInfoField;
  PTCPTTCIPosInfoField = ^TCPTTCIPosInfoField;function TCI_ReqQryPlanInst(ptr:pointer;var strInstID:TPTTCIVarChar16;var strBookDate:TPTTCIDate;var InstructData:CPTTCIInstInfoField):CPTTCIRspInfoField;function  TCI_ReqDownPlanInst(ptr:pointer;var strPlanID:TPTTCIVarChar16;var strBookDate:TPTTCIDate;var pInfoField:CPTTCIInstInfoField; var RealSize:integer):CPTTCIRspInfoField;但是不正确,我在同一个窗体类(TFrmChild)创建的两个Frmchild1,Frmchild2实例的同一位置调用这个函数,第一个窗体调用时正常,但第二个再调用的时候,报地址错误(000000),地址不存在,我跟踪后发现两次声明的(CPTTCIInstInfoField)变量的地址一样。请高手指点,谢谢

解决方案 »

  1.   

    CPTTCIRspInfoField   *   _stdcall   TCI_ReqQryPlanInst
    返回值是指向CPTTCIRspInfoField结构的指针是不是应该是PTCPTTCIPosInfoField类型?
      

  2.   

    To Suton :StdCall我后面都有加,这里忘了写上  如果用PTCPTTCIPosInfoField类型,那只能返回一个CPTTCIRspInfoField结构的指针,但实际返回的却是一个CPTTCIRspInfoField结构的数组的指针
      

  3.   

    CPTTCIRspInfoField这个类型在上面没有定义?
      

  4.   

    TO suton:
    CPTTCIPosInfoField   =   array   of   TCPTTCIPosInfoField;