gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 02:00:56 25 4
gpt4 key购买 nike

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

AutoIt:

#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 调用约定。支持 Cdecl,但您必须通过在您正在调用的函数的返回类型旁边输入 :cdecl 来告诉 AutoIt 您想要使用它。

所以在我的例子中而不是:

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

你会这样:

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

这解决了崩溃问题。

关于调用 C 风格的 DLL 成功,然后 AutoIt 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27317712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com