Joe Guo <x@no.email> wrote:
>请提供详细的信息,例如,什么样子的DLL,DLL 需要初始化么?DLL有没有用string,
array, etc.
谢谢给我答复。
本人使用的DLL很简单:求以输入参数为半径的球的体积和表面积,主程序如下:
#include "stdafx.h"
#include "math.h"
#define M_PI 3.14159
extern "C" __declspec(dllexport) int __cdecl GetSphereSAandVol(double * radius,
double* sa, double* vol);
double GetSA(double radius);
double GetVol(double radius);
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
__declspec(dllexport) int __cdecl GetSphereSAandVol(double * radius, double*
sa, double* vol)
//Calculate the surface area and volume of a sphere with given radius
{
int i;
for(i=0;i<1;i++)
{
if(radius[i] < 0)
{
return false;
break;
}
*sa++ = GetSA(radius[i]);
*vol++ = GetVol(radius[i]);
}
if(i==1)
return true;
}
double GetSA(double radius)
{
return 4 * M_PI * radius * radius;
}
double GetVol(double radius)
{
return 4.0/3.0 * M_PI * pow(radius, 3.0);
}
在使用CIF调用DLL时,出现了如下错误:An exception occurred within
the external code called by a Call Library Node. This may have corrupted
LabVIEW's
memory.You should save any work to a new location and restart LabVIEW.
VI "useDll.vi" was stopped at Call Library Function Node 0x214 of
subVI "useDll.vi"。本人曾单步执行过,发现参数没有传递进去。对于出现的这个问题,已经
超出了我的能力,望再次给与指点。在这里谢过先。
程序见附件