my code:
const ffi = require("ffi");
const ref = require("ref");
let ReadIdcard = ffi.Library("./ReadIdcard.dll", {
"initReadIdcard": ["int", ["pointer"]]
});
let callback = ffi.Callback("void", ["string"],
function(data) {
console.log("data: ", data);
});
console.log("registering the callback");
let z = ReadIdcard.initReadIdcard(callback);
console.log("done");
// Make an extra reference to the callback pointer to avoid GC
process.on("exit", function() {
callback
});
DLL statement:
READIDCARD_API typedef void(*PIDDataCB)(char * pData);
READIDCARD_API int initReadIdcard(PIDDataCB func);
32-bit DLL download:
Link: https://pan.baidu.com/s/1KcKl. password: g7d3
should be the problem of coding. When I try to transcode, I find that I can"t print Chinese normally. DLL is available. Chinese can be displayed normally by using local8bit conversion in QT.
the following English sorry can be displayed normally
< hr >in addition, when I learned that there is a module called fastcall, I wrote it and found that I didn"t seem to call
.const fastcall = require("fastcall");
const Library = fastcall.Library;
const ref = fastcall.ref;
const lib = new Library("ReadIdcard.dll")
.callback({ PIDDataCB: ["void", ["string"]] })
.function({ initReadIdcard: ["int", ["PIDDataCB"]] });
function callback(data) {
console.log("data: ", data);
};
lib.interface.initReadIdcard(callback);
ask the friends of the meeting to help find out what the problem is. No matter it is garbled or fastcall is used, thank you
first.