运行时错误49错误的DLL调用约定 [英] Run Time Error 49 Bad DLL Calling Convention
本文介绍了运行时错误49错误的DLL调用约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尊敬的专家,
我正在尝试从VBA调用Dll中的子例程,但始终收到错误运行时错误49错误的DLL调用约定".关于我在做什么错的任何建议吗?
Dear Experts,
I am trying to call a subroutine in my Dll from VBA but keep getting the error "Run Time Error 49 Bad DLL Calling Convention". Any suggestions on what I am doing wrong?
<code>Declare Sub init_gen_rand Lib "SFMT.dll" (seed As Double)</code>
<code>__declspec( dllexport ) void init_gen_rand(uint32_t seed);</code>
在另一个示例中,我正在调用不带参数的函数,并且确实获得了返回数字,但是即使数据类型为无符号整数uint32_t,返回数字有时还是为负数.怎么了?
In this other example, I am calling a function with no argument and do get a return number but the return numbers are sometimes negative even though the data type is an unsigned integer uint32_t. What is going wrong?
Declare Function gen_rand32 Lib "SFMT.dll" () As Double
<code>__declspec( dllexport ) uint32_t gen_rand32(void);</code>
感谢您的帮助,
Neil
Thanks for your help,
Neil
推荐答案
uint32不是双精度型.我会说这就是问题所在.
A uint32 is not a double. I''d say that''s the issue.
VBA 只能成功导入使用__stdcall
调用约定声明的函数;尝试这种方式:
The VBA can succesfully import only function declared with the__stdcall
calling convention; try this way:
Declare Function gen_rand32 Lib "SFMT.dll" () As Long
__declspec( dllexport ) uint32_t __stdcall gen_rand32(void);
谢谢,有什么建议吗?我也尝试过用Long获得相同的结果.
Thanks, any suggestions? I have also tried Long with the same result.
<pre>Declare Function gen_rand32 Lib "C:\Users\Neil\Documents\Visual Studio 2010\Projects\SFMT\Release\SFMT.dll" () As Long<br />
Declare Sub init_gen_rand Lib "C:\Users\Neil\Documents\Visual Studio 2010\Projects\SFMT\Release\SFMT.dll" (seed As Long)</pre>
这篇关于运行时错误49错误的DLL调用约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文