0

我是新来的,我会尽力解释。我正在编写一些信息工具,该工具需要返回与特定硬件 ATM 相关的一些数据,所以我有它的 API,它的文档与 VB6 C++ 中的代码完全混淆,所以我需要调用 C++ 中原始代码的特定 dll 函数是这样的:

typedef struct _wfsversion
{
    WORD            wVersion;
    WORD            wLowVersion;
    WORD            wHighVersion;
    CHAR            szDescription[WFSDDESCRIPTION_LEN+1];
    CHAR            szSystemStatus[WFSDSYSSTATUS_LEN+1];
} WFSVERSION, * LPWFSVERSION;

//and  Function calls APi and expect some  response.

BOOL Wfs_StartUp(void)
{
    WFSVERSION WfsVersion;
    return (WFSStartUp(RECOGNISED_VERSIONS, &WfsVersion) == WFS_SUCCESS);

#define RECOGNISED_VERSIONS 0X00030203

在 AutoIt 中,我做了以下事情:

#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <Array.au3>
Global Const  $hXFSDLL = DllOpen ( "C:\Coding\infotool\msxfs.dll")
Global Const $RECOGNISED_VERSIONS = "0X00030203"
Global Const $lpWFSVersion = "word wVersion;word wLowVersion;word wHighVersion;char szDescription[WFSDDESCRIPTION_LEN+1];char szSystemStatus[WFSSYSSTATUS_LEN+1]"
$structLPWFSVERSION = DllStructCreate($lpWFSVersion)
DllCall($hXFSDLL,"BOOL","WFSStartUp","dword",$RECOGNISED_VERSIONS, "struct", DllStructGetPtr($structLPWFSVERSION))
ConsoleWrite("wVersion = "&DllstructGetData($structLPWFSVERSION,"wVersion"))
ConsoleWrite(@CRLF)
ConsoleWrite("wLowVersion = "&DllstructGetData($structLPWFSVERSION,"wLowVersion"))
ConsoleWrite(@CRLF)
ConsoleWrite("wHighVersion = "&DllstructGetData($structLPWFSVERSION,"wHighVersion"))
ConsoleWrite(@CRLF)
ConsoleWrite("szDescription = "&DllstructGetData($structLPWFSVERSION,"szDescription"))
ConsoleWrite(@CRLF)
ConsoleWrite("szSystemStatus = "&DllstructGetData($structLPWFSVERSION,"szSystemStatus"))
ConsoleWrite(@CRLF)

作为回应,我没有得到任何数据:

wVersion = 0
wLowVersion = 0
wHighVersion = 0
szDescription = 0
szSystemStatus = 0

所以我想知道我做错了什么?

4

1 回答 1

1

除了 mrt 评论外,我认为您的功能描述是错误的。 WFSStartUp想要结构指针不是结构struct*,所以类型不应该是struct

Local $ret = DllCall($hXFSDLL, "LONG:cdecl", "WFSStartUp", "dword", $RECOGNISED_VERSIONS, "struct*", DllStructGetPtr($structLPWFSVERSION))

编辑:
我更改了上述签名以反映未msxfs.dll使用 stdcall 调用约定的事实,cdecl但这是 AutoIt 文档中DllCall关于调用约定的内容:

默认情况下,AutoIt 使用 'stdcall' 调用方法。要使用 'cdecl' 方法,请在返回类型之后放置 ':cdecl'。

我引用的DllCall文档可以在这里找到:
https ://www.autoitscript.com/autoit3/docs/functions/DllCall.htm

于 2014-11-21T17:56:27.577 回答