我是新来的,我会尽力向大家解释我的最佳表现。我正在编写一些信息工具,它需要返回与特定硬件ATM相关的一些数据,所以我有它的API,它的文档完全混淆了VB6 C++中的代码,所以我需要调用特定的dll函数-- c++中的原始代码是这样的:
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
所以我想知道我做错了什么?
发布于 2014-11-21 17:56:27
除了mrt的评论外,我认为您的功能描述是错误的。WFSStartUp
需要结构指针,而不是结构,所以类型应该是struct*
而不是struct
。
Local $ret = DllCall($hXFSDLL, "LONG:cdecl", "WFSStartUp", "dword", $RECOGNISED_VERSIONS, "struct*", DllStructGetPtr($structLPWFSVERSION))
编辑:
我更改了上面的签名,以反映msxfs.dll
并不使用stdcall调用约定,而是使用cdecl
,因为这是DllCall
的AutoIt文档对调用约定的看法:
默认情况下,AutoIt使用'stdcall‘调用方法。在返回类型后使用'cdecl‘方法place ':cdecl’。
我引用的DllCall
文档可以在这里找到:
https://www.autoitscript.com/autoit3/docs/functions/DllCall.htm
https://stackoverflow.com/questions/27058800
复制相似问题