哈哈,又见面啦, milpas(我带着我的影子去流浪) !

解决方案 »

  1.   

    我在dll里创建了一个adotable,用的是入口参数的adoconnect ,我在dll里用完后就free了.
      

  2.   

    PROJECT2 在 017f:0049692d 的模块
     PROJECT1.DLL 中导致无效页错误。
    Registers:
    EAX=004983c8 CS=017f EIP=0049692d EFLGS=00010283
    EBX=004983c8 SS=0187 ESP=0064fc68 EBP=006501f8
    ECX=00000000 DS=0187 ESI=006501f4 FS=5287
    EDX=006501f4 ES=0187 EDI=006502f8 GS=0000
    Bytes at CS:EIP:
    68 00 04 00 00 8d 44 24 04 50 8b 43 04 50 8b 03 
    Stack dump:错误代码
    Function changtufei(CallNum:String;Time:String;StartTime:string;TimeBlock:string;ADOConnection1:TADOConnection):string;  stdcall;
    var
      i:integer;     //查找区号使用的临时变量
      ITimeLen:integer; //延时时长
      Byouhui:Boolean;    //是否优惠, 如果为特服号码,则该为是否计市话费.
      BspecTF:Boolean;    //是否为特服号码
      Syhfd:string;       //优惠幅度
      SyhtimeS:string ;   //优惠时段开始
      SyhTimeE:string;    //优惠时段结束
      Sgnfj:string;      //国内附加费
      Sgjfj:string;      //国外附加费
      Sgnfw:string;      //国内服务费
      Sgjfw:String;      //国外服务费
      ADOTable1: TADOTable;
      s:string;
      CityName:string;CostRate:string;Service:String;Rate:String;Cost:String;shCost:String ;
    begin
      adotable1:=TADOTable.Create(nil);       //创建Adotable1控件  with adotable1 do begin
        Connection := ADOConnection1;
        CursorType := ctStatic ;
        TableName := 'syscfg';
        Active := True;
       end ;
       AdoTable1.Locate('note','优惠幅度',[loPartialKey]);
       Syhfd:=adotable1.fieldbyname('syscfg').asstring;
       AdoTable1.Locate('note','优惠时段(开始)',[loPartialKey]);
       SyhtimeS:=Adotable1.fieldbyname('syscfg').asstring ;
       AdoTable1.Locate('note','优惠时段(结束)',[loPartialKey]);
       SyhTimeE:=Adotable1.fieldbyname('syscfg').asstring ;   AdoTable1.Locate('note','国内附加费',[loPartialKey]);
       Sgnfj:=Adotable1.fieldbyname('syscfg').asstring ;
       AdoTable1.Locate('note','国际附加费',[loPartialKey]);
       Sgjfj:=Adotable1.fieldbyname('syscfg').asstring ;
       AdoTable1.Locate('note','国内服务费',[loPartialKey]);
       Sgnfw:=Adotable1.fieldbyname('syscfg').asstring ;
       AdoTable1.Locate('note','国际服务费',[loPartialKey]);
       Sgjfw:=Adotable1.fieldbyname('syscfg').asstring ;   Adotable1.Close ;  with adotable1 do begin
        Connection := ADOConnection1;
        CursorType := ctStatic ;
        TableName := 'zonenum';
        Active := True;
       end ;  i:=8 ;
      while i<>2 do       //查找该区号
        begin
        if  adotable1.Locate('number',copy(CallNum,1,i),[loPartialKey]) then break;
        dec(i);
      end;  if i=2 then Result:='该号码不可识别'  //该号码不可识别
      else begin    CityName:=Adotable1.fieldbyname('CityName').asstring; //城市名称
        CostRate:=Adotable1.fieldbyname('CostRate').asstring; //费率
        ITimeLen:= Adotable1.fieldbyname('TimeBlock').asinteger;  //延时时长
        Byouhui:= Adotable1.fieldbyname('youhui').asboolean;        //是否优惠,或者计市话费.
        if ((strtoint(time)-strtoint(TimeBlock)) mod ITimeLen)<>0 then
           cost:=currtostr(((strtoint(time)-strtoint(TimeBlock)) div ITimeLen +1) * strtocurr(CostRate))
          else  cost:=currtostr(((strtoint(time)-strtoint(TimeBlock)) div ITimeLen ) * strtocurr(CostRate));
        if  (Not Adotable1.fieldbyname('specTF').asboolean) and Byouhui
          and (StrTodateTime(starttime)<StrTodateTime(SyhtimeE))
          and (StrTodateTime(starttime)> StrTodateTime(Syhtimes)) then
          cost:=currtostr(strtocurr(cost)*strtocurr(syhfd)/100) ;
        if copy(CallNum,1,2)='00' then
          begin
            service:=currtostr(strtocurr(cost)*(strtocurr(Sgjfw)/100)) ;
            Rate:=sgjfj;
            cost:= currtostr(strtocurr(cost)+strtocurr(service)+strtocurr(rate));
          end
        else
          begin
            cost:=currtostr(strtocurr(cost)*(1+strtocurr(Sgnfw)/100));
            cost:=currtostr(strtocurr(cost)+strtocurr(sgnfj));
          end;
        if  Adotable1.fieldbyname('specTF').asboolean and Byouhui  then
          begin
            shcost:=currtostr(shihuafei((strtoint(time)-strtoint(timeblock)),ADOConnection1));
            cost:= currtostr(strtocurr(cost)+strtocurr(shcost));
          end;        result:=CityName;//+':'+CostRate+':'+Service+':'+Rate+':'+Cost+':'+shCost;
      end;
            adotable1.Free;
    end;exports
     shihuafei,changtufei;end.
    临时测试用的代码