当前位置: 代码迷 >> Delphi >> 关于Delphi7 调用C++ dll 传参有关问题
  详细解决方案

关于Delphi7 调用C++ dll 传参有关问题

热度:4609   发布时间:2013-02-25 00:00:00.0
关于Delphi7 调用C++ dll 传参问题。
C++ DLL h文件:
C/C++ code
extern "C" __declspec(dllexport)   unsigned int __stdcall WINAPI GetA(float *fData,int iNum1,int iNum2);



Delphi7 加载DLL:
Delphi(Pascal) code
function F_GetA(fData:Array of Single;iNum1,iNum2:Integer):Cardinal;stdcall;external 'MyDLL.dll' name GetA;



Delphi(Pascal) code
var  fData:Array[0..3000] of Single;//输出的浮点型数组  iNum1:Integer;//输入的数据  iNum2:Integer;//输入的数据iNum1:=10;iNum2:=20;if(F_GetA(fData,iNum1,iNum2)=0) then  ShowMessage('失败。')else  ShowMessage('成功。');


结果:
通过调试发现,在调用F_GetA过程中,
1、iNum1=3000(随fData长度变化);
2、iNum2=10(随iNum1设置变化);

初次使用delphi7,这样的结果,不知所云的#¥@%


------解决方案--------------------------------------------------------
c++中实现了什么代码