Delphi 调用DLL 问题,当掉用到Read_TestData函数时,就提示除数为零的问题(200)

  • 主题发起人 主题发起人 wxm337766
  • 开始时间 开始时间
W

wxm337766

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,inifiles, Dialogs, StdCtrls, ExtCtrls, Menus;typePVCI_PVI_READ=^TVCI_PVI_READ;TVCI_PVI_READ=recordTest_Time:Cardinal;Test_NJ0:double;Test_NSpeed0:double;Test_WSpeed0:double;status:Cardinal;Test_phase0:double;
end;
typePVCI_PCI_Parameter=^TVCI_PCI_Parameter;TVCI_PCI_Parameter=recordNM_Range:double;NM_F:Byte;dotD:double;scaleN:Byte;scaleW:Byte;BD_tempe:Byte;Use_tempe:Byte;F_xs:double;PH_xs:double;
end;
typeOpenDevice=Function():Cardinal;CloseDevice=Function():Cardinal;Set_TestTime=function(TimePhrase0:Cardinal;TimeWSpeed0:Cardinal):Cardinal;Read_TestData=function(para:PVCI_PCI_Parameter;p0bj:PVCI_PVI_READ):Cardinal;StdCall;
TForm1 = class(TForm) Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Timer1: TTimer;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
Label13: TLabel;
Label14: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure N2Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
PFunc,PFuncReadData,PFuncSetTime,PFuncWrite:TFarProc;Moudle,MoudleReadData,MoudleSetTime,MoudleWrite:THandle;pj1:PVCI_PVI_READ;pj2:PVCI_PCI_Parameter;implementation uses unit2;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);varini : Tinifile;
filename : string;
begin
ini:=Tinifile.Create('Set.ini');filename:=ExtractFilePath(paramstr(0))+'set.ini';ini:=Tinifile.Create(filename);//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////MoudleSetTime:=LoadLibrary('ntpci3.dll');
if(MoudleSetTime>32)then
begin
PFuncSetTime:=GetProcAddress(MoudleSetTime,'Set_TestTime');Set_TestTime(PFuncSetTime)(strtoint(ini.ReadString('niujuka','niuju0caiyangshijian','0')),strtoint(ini.ReadString('niujuka','waizhuansucaiyangshijian','0')));
end;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////MoudleWrite:=LoadLibrary('ntpci3.dll');
if(MoudleWrite>32)then
begin
PFuncWrite:=GetProcAddress(MoudleWrite,'write');write(PFuncWrite)('g');
end;
timer1.Interval:=250;timer1.Enabled:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Moudle:=LoadLibrary('ntpci3.dll');
if(Moudle>32)then
begin
PFunc:=GetProcAddress(Moudle,'OpenDevice');
if(OpenDevice(PFunc)()=0)then
showmessage('设备开启失败') else
showmessage('设备开启成功');
end;
label1.Caption:='扭矩:';label2.Caption:='内转速:';label3.Caption:='相位角:';label4.Caption:='实时时间:';label5.Caption:='外转速:';label13.Caption:='状态:';timer1.Enabled:=false;
end;
procedure TForm1.Timer1Timer(Sender: TObject);varini : Tinifile;
filename : string;
begin
ini:=Tinifile.Create('Set.ini');filename:=ExtractFilePath(paramstr(0))+'set.ini';ini:=Tinifile.Create(filename);//////////////////////////////////////////////////{Format('%*.*f', [5,3,strtofloat(FloattostrF(strtoFloatdef(ini.ReadString('AIK','Ch0','0'),0)*strtofloat(Edit7.Text)+strtofloatdef(ini.ReadString('AIb','Ch0','0'),0),ffFixed,7,7))]);}new(pj1);pj1^.Test_Time:=444;pj1^.Test_NJ0:=7777;pj1^.Test_NSpeed0:=888;pj1^.Test_WSpeed0:=666;pj1^.status:=88;pj1^.Test_phase0:=6666;new(pj2);pj2^.NM_Range:=strtoFloatdef(ini.ReadString('niujuka','xishu','0'),0);pj2^.NM_F:=strtoint(ini.ReadString('niujuka','neichishu','0'));pj2^.dotD:=0;pj2^.scaleN:=strtoint(ini.ReadString('niujuka','neichishu','0'));pj2^.scaleW:=strtoint(ini.ReadString('niujuka','waichishu','0'));pj2^.BD_tempe:=strtoint(ini.ReadString('niujuka','biaodingwendu','0'));pj2^.Use_tempe:=strtoint(ini.ReadString('niujuka','shiyongwendu','0'));pj2^.F_xs:=1.0;pj2^.PH_xs:=1.0;MoudleReadData:=LoadLibrary('ntpci3.dll');
if(MoudleReadData>32)then
begin
PFuncReadData:=GetProcAddress(MoudleReadData,'Read_TestData');
if(Read_TestData(PFuncReadData)(pj2,pj1)=1)then
begin
label6.Caption:=floattostr(pj1^.Test_NJ0);label7.Caption:=floattostr(pj1^.Test_NSpeed0);label8.Caption:=floattostr(pj1^.Test_phase0);label9.Caption:=inttostr(pj1^.Test_Time);label10.Caption:=floattostr(pj1^.Test_WSpeed0);label14.Caption:=inttostr(pj1^.status);
end;
end;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
freeLibrary(Moudle);freeLibrary(MoudleSetTime);freeLibrary(MoudleReadData);Dispose(pj1);Dispose(pj2);
end;
procedure TForm1.N2Click(Sender: TObject);
begin
form2.ShowModal;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
end.
Delphi 调用DLL 问题,当掉用到Read_TestData函数时,就提示除数为零的问题,谁能帮忙看看,调试一下,谢谢
 
仔细检查下dll的函数,看具体什么问题把这种问题发到编程问题里面去吧,好多高手很少来这儿的
 
有几年没来这里灌水了,[:D][:D]该调试dll,楼主调错了位置
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
520
import
I
后退
顶部