调用 C 样式 DLL 成功,然后 AutoIt 崩溃



我正在尝试从AutoIt 3(最新版本)调用一个名为"通用语音"的C样式库。我从正在调用的函数中获得了所需的操作,但是在收到响应AutoIt崩溃后,说"AutoIt已停止工作,Windows可以搜索解决方案..."我做错了什么吗?

自动:

#notrayicon
dllcall("UniversalSpeech.dll", "int", "speechSayA", "str", "test 123", "int", 1)
sleep(1000)

通用语音.h:

#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似乎不喜欢它。

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

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

所以就我而言,而不是:

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

你会这样:

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

这解决了崩溃。

相关内容

最新更新