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

问题描述 投票:1回答:1

我试图从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似乎并不喜欢它。

c dll autoit
1个回答
3
投票

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

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

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

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

你会这样:

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

这解决了崩溃。

© www.soinside.com 2019 - 2024. All rights reserved.