VC functions all use _stdcallfunctions exported using .def file (e.g. AliasFunc@R_419_6889@ = _Func@R_419_6889@@NumCallArgBytes)Existing C DLL was revised to have some new call arguments (revised function @R_419_6889@s,built to new dll @R_419_6889@)Functions with unrevised call arguments work when calling the new DLLFunctions with revised call arguments do not work when calling the new DLL (all call arguments are garbage on entry)Call arguments are several input doubles and a few return double*Prototype.h call deFinition matches c source code deFinitionVisual Basic declarations to new DLL match in style those to the old DLL (several ByVal double input args and a few ByRef return args)
在调试VC调试器之前,VB调试器中的参数看起来很好,它们是垃圾(例如1.34867e-308,3.493732-88等).
我很感激任何关于可能原因的想法.几天来,我一直在努力解决这个问题.顺便说一句,我不选择使用遗留代码!
下面是C头原型,.DEF定义和VB声明.
头文件定义:
LONG _stdcall SYSDll_FRoulSlIDeXa( double ATest,double Hc,double Hivr,double Eeq,double Rx,double Rk,double L,double U,double SlRol,double R,double Wlc,double Wpc,double Mu,double MuOil,double Cor2AL,double Fs,double Ft,double *FRoul,double *FSlID);
.DEF文件定义:
liBRARY "SYSx32d10a"DESCRIPTION 'SYSx Dlls'EXPORTS SYSDll_FRoulSlIDeXa = _SYSDll_FRoulSlIDeXa@144
VB6声明:
Declare Function SYSDll_FRoulSlIDeXa lib "SYSX32D10A.DLL" ( _ ByVal ATest As Double,ByVal Hc As Double,ByVal Hivr As Double,_ ByVal Eeq As Double,ByVal rx As Double,ByVal Rk As Double,_ ByVal L As Double,ByVal U As Double,ByVal SlRol As Double,_ ByVal r As Double,ByVal Wlc As Double,ByVal Wpc As Double,_ ByVal Mu As Double,ByVal MuOil As Double,ByVal Cor2AL As Double,_ ByVal Fs As Double,ByVal Ft As Double,_ FRoul As Double,FSlID As Double)
注意:我已经在最后两个参数上尝试了显式的ByRef,而不是依赖于默认传递约定为ByRef.
解决方法 您VB声明不包含该函数的返回类型.除非您没有显示DEFxxx语句,否则这意味着VB期望Variant.由于Variant函数使用隐藏参数返回其值,因此堆栈将不对齐.仅这一点就可以导致你所看到的.解决方案是将正确的返回类型添加到VB Declare.
总结以上是内存溢出为你收集整理的从VB6调用C DLL传递垃圾数据的参数?全部内容,希望文章能够帮你解决从VB6调用C DLL传递垃圾数据的参数?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)