调用C风格的DLL成功,然后AutoIt崩溃

时间:2014-12-05 14:08:32

标签: c dll autoit

我正试图从AutoIt 3(最新版本)调用名为“通用语音”的C风格库。我从我正在调用的函数中得到了所需的操作但是在我得到响应之后AutoIt崩溃说“AutoIt已经停止工作,Windows可以搜索解决方案......”我做错了吗?

的AutoIt:

#notrayicon
dllcall("UniversalSpeech.dll", "int", "speechSayA", "str", "test 123", "int", 1)
sleep(1000)
普遍的发言:

#ifndef ____UNIVERSAL_SPEECH_H__
#define ____UNIVERSAL_SPEECH_H__
#if defined __WIN32 || defined __WIN64
#define export __declspec(dllexport)
#else
#error Platform currently unsupported
#endif
#ifdef __cplusplus
extern "C" {
#endif
int export speechSayA (const char* str, int interrupt) ;
#ifdef __cplusplus
} // extern "C"
#endif
#endif

我在其他编程语言中成功地做到了这一点,但AutoIt似乎并不喜欢它。

1 个答案:

答案 0 :(得分:3)

" binhnx"在AutoIt论坛上解决了我的问题:

此库使用cdecl调用约定,默认情况下AutoIt使用stdcall调用约定。支持Cdecl,但您必须通过在您正在呼叫的函数的返回类型旁边输入:cdecl告诉AutoIt您想要使用它。

所以在我的情况下,而不是:

dllcall("UniversalSpeech.dll", "int"...)

你是这样的:

dllcall("UniversalSpeech.dll", "int:cdecl"...)

这解决了崩溃问题。