主题:Delphi调用VC++写的DLL中遇到的问题~~
VC++写的DLL源代码为:
extern "C" __declspec( dllexport ) int Init()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CLsrEllipseApp *pApp = ( CLsrEllipseApp* )AfxGetApp();
return pApp->Init();
}
extern "C" __declspec( dllexport ) void SetParameter( double dVel, double dOffVel, double dLaserOn, double dPoly,
double dLaserOff, double dPos, double dDis, long lFreq, double dPower )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CLsrEllipseApp *pApp = ( CLsrEllipseApp* )AfxGetApp();
pApp->SetParameter( dVel, dOffVel, dLaserOn, dPoly, dLaserOff, dPos, dDis, lFreq, dPower );
}
extern "C" __declspec( dllexport ) void TestLaser()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CLsrEllipseApp *pApp = ( CLsrEllipseApp* )AfxGetApp();
pApp->TestLaser();
}
extern "C" __declspec( dllexport ) void MarkEllipse( double dX, double dY, double dWid, double dHei, double dRotAng )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CLsrEllipseApp *pApp = ( CLsrEllipseApp* )AfxGetApp();
pApp->MarkEllipse( dX, dY, dWid, dHei, dRotAng );
}
extern "C" __declspec( dllexport ) void Close()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CLsrEllipseApp *pApp = ( CLsrEllipseApp* )AfxGetApp();
pApp->Close();
}
这里包含了5个函数:
我在Delphi中调用这些参数的代码为:
procedure TMainInterface.Button1Click(Sender: TObject);
var
dVel:Longint;
dOffVelP:Double;
dLaserOn:Double;
dPoly:Double;
dLaserOff:Double;
dPos:Double;
dDis:Double;
lFreq:Longint;
dPower:Double;
dX:Double;
dY:Double;
dWid:Double;
dHei:Double;
dRotAng:Double;
Init:function:boolean;
DllModule:THandle;
SetParameter:function:Longint;
MarkEllipse:function:Longint;
begin
DllModule:=LoadLibrary('LsrEllipse.dll'); //盢"LsrEllipse.dll"ゅン琈禜琈甮秈秸ノ秈祘丁
if DllModule<>0 then
@Init:=GetProcAddress(DllModule,'Init'); //眔DLLいㄧ计Init()
@SetParameter:=GetProcAddress(DllModule,'SetParameter'); //眔DLLいㄧ计SetParameter()
@MarkEllipse:=GetProcAddress(DllModule,'MarkEllipse'); //眔DLLいㄧ计MarkEllipse()
if (@Init<>nil)and(@Init<>nil)then
if (@SetParameter<>nil)and(@SetParameter<>nil)then
if (@MarkEllipse<>nil)and(@MarkEllipse<>nil)then
begin
dVel:=100;
dOffVelP:=2000;
dLaserOn:=0.0002;
dPoly:=0.2;
dLaserOff:=0.6;
dPos:=1;
dDis:=0.2;
lFreq:=1000;
dPower:=0.6;
dX:=10.0;
dY:=10.0;
dWid:=2.0;
dHei:=8.0;
dRotAng:=45.0;
Init(); //秸ノㄧ计Init
SetParameter(); //秸ノㄧ计SetParameter
MarkEllipse(); //秸ノㄧ计MarkEllipse
end;
end;
但是我调试的过程中发现出现这样的错误
Project Project1.exe raised exception class EInvalidOp with message 'Invalid floating point operation'.Process stoped.
请大家帮我指正错误 谢谢~~~~~~~~
extern "C" __declspec( dllexport ) int Init()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CLsrEllipseApp *pApp = ( CLsrEllipseApp* )AfxGetApp();
return pApp->Init();
}
extern "C" __declspec( dllexport ) void SetParameter( double dVel, double dOffVel, double dLaserOn, double dPoly,
double dLaserOff, double dPos, double dDis, long lFreq, double dPower )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CLsrEllipseApp *pApp = ( CLsrEllipseApp* )AfxGetApp();
pApp->SetParameter( dVel, dOffVel, dLaserOn, dPoly, dLaserOff, dPos, dDis, lFreq, dPower );
}
extern "C" __declspec( dllexport ) void TestLaser()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CLsrEllipseApp *pApp = ( CLsrEllipseApp* )AfxGetApp();
pApp->TestLaser();
}
extern "C" __declspec( dllexport ) void MarkEllipse( double dX, double dY, double dWid, double dHei, double dRotAng )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CLsrEllipseApp *pApp = ( CLsrEllipseApp* )AfxGetApp();
pApp->MarkEllipse( dX, dY, dWid, dHei, dRotAng );
}
extern "C" __declspec( dllexport ) void Close()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CLsrEllipseApp *pApp = ( CLsrEllipseApp* )AfxGetApp();
pApp->Close();
}
这里包含了5个函数:
我在Delphi中调用这些参数的代码为:
procedure TMainInterface.Button1Click(Sender: TObject);
var
dVel:Longint;
dOffVelP:Double;
dLaserOn:Double;
dPoly:Double;
dLaserOff:Double;
dPos:Double;
dDis:Double;
lFreq:Longint;
dPower:Double;
dX:Double;
dY:Double;
dWid:Double;
dHei:Double;
dRotAng:Double;
Init:function:boolean;
DllModule:THandle;
SetParameter:function:Longint;
MarkEllipse:function:Longint;
begin
DllModule:=LoadLibrary('LsrEllipse.dll'); //盢"LsrEllipse.dll"ゅン琈禜琈甮秈秸ノ秈祘丁
if DllModule<>0 then
@Init:=GetProcAddress(DllModule,'Init'); //眔DLLいㄧ计Init()
@SetParameter:=GetProcAddress(DllModule,'SetParameter'); //眔DLLいㄧ计SetParameter()
@MarkEllipse:=GetProcAddress(DllModule,'MarkEllipse'); //眔DLLいㄧ计MarkEllipse()
if (@Init<>nil)and(@Init<>nil)then
if (@SetParameter<>nil)and(@SetParameter<>nil)then
if (@MarkEllipse<>nil)and(@MarkEllipse<>nil)then
begin
dVel:=100;
dOffVelP:=2000;
dLaserOn:=0.0002;
dPoly:=0.2;
dLaserOff:=0.6;
dPos:=1;
dDis:=0.2;
lFreq:=1000;
dPower:=0.6;
dX:=10.0;
dY:=10.0;
dWid:=2.0;
dHei:=8.0;
dRotAng:=45.0;
Init(); //秸ノㄧ计Init
SetParameter(); //秸ノㄧ计SetParameter
MarkEllipse(); //秸ノㄧ计MarkEllipse
end;
end;
但是我调试的过程中发现出现这样的错误
Project Project1.exe raised exception class EInvalidOp with message 'Invalid floating point operation'.Process stoped.
请大家帮我指正错误 谢谢~~~~~~~~