Closed gloomcheng closed 5 years ago
My mistake, I did not confirm that Electron run on 32bit The correct code should be as below
const DVR = ffi.Library('dhnetsdk.dll', {
/**
* LLONG CLIENT_DownloadByTimeEx(
* LLONG lLoginID,
* int nChannelId,
* int nRecordFileType,
* LPNET_TIME tmStart,
* LPNET_TIME tmEnd,
* char *sSavedFileName,
* fTimeDownLoadPosCallBack cbTimeDownLoadPos,
* LDWORD dwUserData,
* fDataCallBack fDownLoadDataCallBack,
* LDWORD dwDataUser,
* void* pReserved = NULL
* );
*/
CLIENT_DownloadByTimeEx: [ref.types.int64, [ref.types.int64, ref.types.int, ref.types.int, NetTimePtr, NetTimePtr, 'string', 'pointer', ref.types.ulong, 'pointer', ref.types.ulong, 'pointer']],
});
Because this Library defined LDWORD is DWORD for 32bit and INT64 for 64bit.
I want to call a method from DLL, I've wrote the method to JS code as below
The seventh argument was callback function defined as below
I've checked Ref document to confirm the way I used should be correct, but when I called the CLIENT_DownloadByTimeEx function by code as below
The last line return error message:
Uncaught TypeError: error setting argument 7 - writeInt64: Number/String 64-bit value required
I've checked the seventh argument could be pass by callback function, why it need to setting 64-bit value? BTW, I've tried alter code as below but not work also.
let timeDownloadPosCallback = ffi.Callback(ref.types.int64, ...
Please help to clarify what issue really is, for instance, wrong ref type in callback function or library function, thanks for advice.