写了一个dll文件,调用c写的动态库,然后书写一个c写的测试程序。ok.但是如过我使用delphi的话。就会报:floating point division by zero。那位遇到过,指点一二。谢谢啊

解决方案 »

  1.   

    该dll 文件是用c写的。但是我使用delphi调用它就报错。用c写的就可以通过
      

  2.   

    应该是在DELPHI中参数或者指示字没有声明对
      

  3.   

    我跟踪了下,就是到fstp指令集处。网上也搜了下。,有位高手说是类型转换问题,也没有下文了。郁闷!debug就试到进入dll函数接口时报错误了。查delphi帮助说是语言异常。
      

  4.   

    DLL的声明,我使用WINAPI的,并且我的delphi程序也没有向代码内部传参数,只是调用funInit()就报错误了.使用c/c++写的就没有
      

  5.   

    #ifndef __TESTOPT_H__
    #define __TESTOPT_H__#ifdef __cplusplus
    extern "C" {
    #endif
    int WINAPI EpoptInit();#ifdef __cplusplus
    }
    #endif#endif
    --------------#include "stdafx.h"
    #include "stdio.h"
    #include "stdlib.h"#include "testopt.h"
    #include "windows.h"
    #include "process.h"/************************************************************************/
    /* 初始化函数 0 成功,-1失败                                                          */
    /************************************************************************/
    int WINAPI EpoptInit()
    {
    int  recResult = TAOecInit(NULL); //TAOecInit是另外厂商提供的,无法在跟踪了
    if (recResult!=0)
    {
    g_bInit=false;
    MakeErrCodeForRec("TAOecInit",ecResult);
    return -1;
    }
    WriteLogFile("初始化ec成功!");
    return 0;
    }------------------
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls; { 
      function EpoptInit() : longint;stdcall;external 'testdll.dll';
      
     }type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        
      private
        { Private declarations }
      public
        { Public declarations }
      end;
     
      function EpoptInit() : Longint;stdcall;external 'testdll.dll';var
      Form1: TForm1;implementation
      
    {$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
            ThreadId : DWord;
            iResult : Integer;
            i : Integer;
            arrayHandle : array[0..11] of THandle;
    begin
            iResult := EpoptInit();//此处出错了,
            if iResult <> 0 then
            begin
                    exit;
            end;end;
      

  6.   

    C默认的调用方式好象是cdecl,在DELPHI你声明的stdcall
    可能是这个的问题。把它们声明成一致的。
      

  7.   

    在vc的windef.h文件中是这么定义WINAPI的#define WINAPI      __stdcall,所以madyak您说的好像还不对
      

  8.   

    TAOecInit(NULL); 是什么类型的接口?Uses ComObj;一下或手工
    COM库:CoInitialize{Ex}、CoUnitialize   
     OLE系统:OleInitialize、OleUnitialize
      

  9.   

    在delphi里为什么不直接调用TAOecInit?
      

  10.   

    回复楼上的。因为TAOecInit接口是用c写的。他涉及到很多.h,.c文件.所以我们是现封装成dll。在由delphi来调用。
      

  11.   

    不太明白,
    在一般的c编译器中:
    c 的 int类型 为16位整数
    应该和
    delphi的Smallint 相当.c的long类型 =D的longint类型.
    是不是这里有问题?
      

  12.   

    在你的delphi主程序中,加入下面这条语句:
    Set8087CW(Default8087CW or $3F); 用于屏蔽CPU的浮点数被零除异常信息的。