I am confused。 When using FFI-NAPI - Dll 。 The return value does not receive anything。 But print out the content (stdut) at the terminal。 I will post part of the code below and keep trying. I guess it will work after using FF-callback, but I'm not sure. Could you please take a look at it for me 。
Here is my code:
import { myDll } from './utils/DllImport'
....
....
ipcMain.on('GetAdbProp', () => {
var nameBuffer = Buffer.alloc(10240);
nameBuffer.fill(0);
nameBuffer.write('', 0, "ascii");
const res=myDll.GetAdbProp('factory.board', nameBuffer)
console.log(res,nameBuffer)
})
const ffi = require('ffi-napi')
const ref=require('ref-napi')
let path = require('path')
let dllFilePath;
if (process.env.NODE_ENV === 'development') {
dllFilePath = path.join(process.cwd(), './resources/extraResources','AdbHandler.dll')
} else {
dllFilePath = path.join(process.cwd(), './resources/extraResources','AdbHandler.dll')
}
let myDll =ffi.Library(dllFilePath, {
'GetAdbProp':
[
ref.types.bool, ['string','char *'],
],
})
module.exports = {
myDll
}
Print the result :
\platform-tools\adb.exe shell "getprop | grep factory.board"
[factory.board.acclsensor]: [1]
[factory.board.brightness]: [0]
[factory.board.bt]: [1]
[factory.board.charge]: [-1]
[factory.board.cmd]: [0][factory.board.gyrosensor]: [1]
[factory.board.headphone]: [0]
[factory.board.info_check]: [0]
[factory.board.key]: [0]
[factory.board.lcd]: [0]
[factory.board.led]: [0]
[factory.board.mic_hp]: [0]
[factory.board.mic_mic]: [0]
[factory.board.otg]: [0]
[factory.board.psensor]: [0]
[factory.board.sdcard]: [-1]
[factory.board.spk]: [0]
[factory.board.wifi]: [1]
res,nameBuffer
true <Buffer@0x000062140074A800 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 10190 more bytes>
>
const res=myDll.GetAdbProp('factory.board', nameBuffer)
This string of code returns an empty value, and the buffer hasn't changed, but my terminal has something,
How can I use this printout(stduit content),The following these。
\platform-tools\adb.exe shell "getprop | grep factory.board"
[factory.board.acclsensor]: [1]
[factory.board.brightness]: [0]
[factory.board.bt]: [1]
[factory.board.charge]: [-1]
.....
....
.....
thank you