在库中找不到函数符号

couldn't find function symbol in library

声明 SCardStatus 函数导致错误:"couldn't find function symbol in library"

代码如下:

Cu.import('resource://gre/modules/ctypes.jsm');
var is64bit = ctypes.voidptr_t.size == 4 ? false : true;
var ifdef_UNICODE = true;
var TYPES = {
    ABI: is64bit ? ctypes.default_abi : ctypes.winapi_abi,
    CHAR: ctypes.char,
    DWORD: ctypes.uint32_t,
    LONG: ctypes.long,
    LPCVOID: ctypes.voidptr_t,
    ULONG_PTR: is64bit ? ctypes.uint64_t : ctypes.unsigned_long,
    WCHAR: ctypes.jschar,
};
TYPES.LPSTR = TYPES.CHAR.ptr;
TYPES.LPDWORD = TYPES.DWORD.ptr;
TYPES.LPWSTR = TYPES.WCHAR.ptr;
TYPES.SCARDHANDLE = TYPES.ULONG_PTR;
TYPES.LPBYTE = TYPES.LPSTR;
TYPES.LPTSTR = ifdef_UNICODE ? TYPES.LPWSTR : TYPES.LPSTR;
var cardLib = ctypes.open('Winscard');
var SCardStatus = cardLib.declare('SCardStatus', TYPES.ABI, TYPES.LONG, TYPES.SCARDHANDLE, TYPES.LPTSTR, TYPES.LPDWORD, TYPES.LPDWORD, TYPES.LPDWORD, TYPES.LPBYTE, TYPES.LPDWORD );

我猜 TYPES.LPBYTE 不正确,根据 https://msdn.microsoft.com/en-us/library/windows/desktop/aa379803%28v=vs.85%29.aspx ,LPBYTE 应该是一个指向 32 字节缓冲区的指针,该缓冲区从当前插入的卡接收 ATR 字符串(如果可用)。但是我无法修复它,我感谢任何先进的帮助。

在 winapi 中,如果函数有两个版本,unicode 版本和 ascii 版本,如果它采用字符串。所以文档显示它接受字符,所以在页面上它显示:SCardStatusW (Unicode) and SCardStatusA (ANSI) 所以你必须这样定义它:var SCardStatus = cardLib.declare(ifdef_UNICODE ? 'SCardStatusW' : 'SCardStatusA', ....