| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2987 人关注过本帖
标题:VC 调用 delphi 写的一个 dll 导出函数,报栈溢出的异常的问题!
只看楼主 加入收藏
kenny1981050
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-5-1
收藏
 问题点数:0 回复次数:0 
VC 调用 delphi 写的一个 dll 导出函数,报栈溢出的异常的问题!
问题具体是这样的,厂家提供的一个用delphi写的一个dll,而我们公司的软件是用vc开发的,在调用一个delphi导出函数时报栈溢出,后来发现是这个导出函数的参数用了delphi的string,我自己又用delphi卦装了这个dll,把string换成pchar,但还是报栈溢出,有点要崩溃了,
delphi:
原厂家导出函数申明:
function purchasePower(comport: integer;
  MeterType: integer;
  userIDNo: string;
  seq: integer;
  purTimes: integer;
  PurQty: double;
  PurDate: string;
  CmdByte: integer;
  BalDate: integer;
  WarnQty: double;
  CoemptionQty: double;
  PurPrice: double): integer; stdcall; far; external 'WS_4428_D6_SDDI.dll';
自己卦装函数导出:
function LP_PurchasePower(comport: integer;
                          MeterType: integer;
                          userIDNo: pchar;
                          seq: integer;
                          purTimes: integer;
                          PurQty: double;
                          PurDate: pchar;
                          CmdByte: integer;
                          BalDate: integer;
                          WarnQty: double;
                          CoemptionQty: double;
                          PurPrice: double): integer;stdcall;
begin
     try
          result:= purchasePower(comport,MeterType,userIDNo,seq,PurTimes,PurQty,
                                 strPurDate,CmdByte,BalDate,WarnQty,coemptionQty,PurPrice);
     except
          result:= 1;
     end;
end;
exports LP_PurchasePower;
VC调用delphi导出函数申明:
typedef  int (__stdcall *PFunPurchasePower)(int iCom,int iMeterType,char*userIDNo,int iSeq,int iPurTimes,                                        double dbPurQty,char* PurDate,int uCmdByte,int iBalDate,                                            double dbWarnQty,double dbCoemptionQty,double dbPurPrice);
VC高用delphi导出涵数:
int CWSReader::PurchasePower(int iCom,int iMeterType,char* szUserIDNO,int iSeq,int iPurTimes,
                             double dbPurQty,char* szPurDate,int uCmdByte,int iBalDate,
                             double dbWarnQty,double dbCoemptionQty,double dbPrice)
{
    if( m_hModule == NULL )
        return -1;

    PFunPurchasePower PPurchasePower = (PFunPurchasePower)GetProcAddress(m_hModule,"LP_PurchasePower");
    if( PPurchasePower == NULL )
        return -1;

    int iRet = 0;
    try
    {
        iRet = PPurchasePower(iCom,iMeterType,szUserIDNO,iSeq,iPurTimes,dbPurQty,szPurDate,uCmdByte,iBalDate,dbWarnQty,dbCoemptionQty,dbPrice);
    }
    catch (CMemoryException* e)
    {
        e->ReportError();
    }
    catch (CFileException* e)
    {
        e->ReportError();
    }
    catch (CException* e)
    {
        e->ReportError();
    }

    return iRet;
}

就算我把自己卦装的delphi导出函数改成以下不用VC传进来的参数,还是一样报错:
function LP_PurchasePower(comport: integer;
                          MeterType: integer;
                          userIDNo: pchar;
                          seq: integer;
                          purTimes: integer;
                          PurQty: double;
                          PurDate: pchar;
                          CmdByte: integer;
                          BalDate: integer;
                          WarnQty: double;
                          CoemptionQty: double;
                          PurPrice: double): integer;stdcall;
var
    iPort:integer;
    uMType:integer;
    iSeq:integer;
    iPurTimes:integer;
    dbPurQty:double;
    strUserIDNO:string;
    strPurDate:string;
    iCmdByte:integer;
    iBalDate:integer;
    dbWarnQty:double;
    dbCQty:double;
    dbPrice:double;
begin
     try

          //strPurDate:= '20140501';
          //result:= purchasePower(comport,MeterType,userIDNo,seq,PurTimes,PurQty,
          //                       strPurDate,CmdByte,BalDate,WarnQty,coemptionQty,PurPrice);
          FillChar(strUserIDNO,sizeof(strUserIDNO),#0);
          FillChar(strPurDate,sizeof(strPurDate),#0);
          iPort:= 100;
          uMType:= 16;
          iSeq:= 1;
          iPurTimes:= 31;
          dbPurQty:= 2;
          strUserIDNO:= '0106017592';
          strPurDate:= '20140501';
          iCmdByte:= 13;
          iBalDate:= 1;
          dbWarnQty:= 5;
          dbCQty:= 999;
          dbPrice:= -1;
          result:= purchasePower(iPort,uMType,strUserIDNO,iSeq,iPurTimes,dbPurQty,strPurDate,iCmdByte,iBalDate,dbWarnQty,dbCQty,dbPrice);
     except
          result:= 1;
     end;
end;
搜索更多相关主题的帖子: function double 开发 软件 
2014-05-01 17:19
快速回复:VC 调用 delphi 写的一个 dll 导出函数,报栈溢出的异常的问题!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014965 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved