Delphi中写的Dll,其接口函数格式
SendReal (channel,flag,date1,time1,value1,value2,value3,value4,value5,value6,value7:Double):single;VC中如何调用该dll的接口函数!
//***********************************
typedef float(_cdecl *Connect)(double i);
HINSTANCE hinstDLL=NULL;
hinstDLL=LoadLibrary("dllname.dll");
if (hinstDLL)
{
Connect Proc;
Proc = (Connect)GetProcAddress (hinstDLL,"SendReal");
float iValue = Proc(1,0,20050302,124701,1,2,3,4,5,6,7);//出错
FreeLibrary(hinstDLL); }
error:
error C2197: 'float (__cdecl *)(double)' : too many actual parameters
SendReal (channel,flag,date1,time1,value1,value2,value3,value4,value5,value6,value7:Double):single;VC中如何调用该dll的接口函数!
//***********************************
typedef float(_cdecl *Connect)(double i);
HINSTANCE hinstDLL=NULL;
hinstDLL=LoadLibrary("dllname.dll");
if (hinstDLL)
{
Connect Proc;
Proc = (Connect)GetProcAddress (hinstDLL,"SendReal");
float iValue = Proc(1,0,20050302,124701,1,2,3,4,5,6,7);//出错
FreeLibrary(hinstDLL); }
error:
error C2197: 'float (__cdecl *)(double)' : too many actual parameters
delphi的是pascal调用约定,也就是_stdcall,
而VC的不同,
把这句改一下试试:
Proc = (_stdcall)(Connect)GetProcAddress (hinstDLL,"SendReal");