You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to outline what I did to get this to work since ffi-napi was crashing on import. I tried to follow the build instructions(I'm pretty new at this) but there are some missing issues. Specifically npm i koffi gave an error about it missing in the registry: [I spend a lot of time on ffi-napi trying to setup some generate binding generators only to find out it wouldn't work ;/ I should have tried something simpler.
Try installing using npm:
Specifically, but note that I tried various versions and the dev was my build,
npm install koffi
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fkoffi - Not found
npm ERR! 404
npm ERR! 404 '@types/koffi@^3.0.0-dev' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
Clone the rygel sources, follow the instructions given by koffi:
cd src/koffi
node ../cnoke/cnoke.js
passed
cd src/koffi/test
node ../../cnoke/cnoke.js
node test.js
Fail because "require" is missing. Maybe there is more to it
To get it to work in my package since step 1 fails. To do this use npm link while in src/koffi then use npm link koffi in the app dir. It should put koffi in the types dir and it should be accessible using const koffi = require('koffi');
I used the following code to test and it worked.
const koffi = require('koffi');
// Load the shared library
const lib = koffi.load('user32.dll');
I'd like to outline what I did to get this to work since ffi-napi was crashing on import. I tried to follow the build instructions(I'm pretty new at this) but there are some missing issues. Specifically npm i koffi gave an error about it missing in the registry: [I spend a lot of time on ffi-napi trying to setup some generate binding generators only to find out it wouldn't work ;/ I should have tried something simpler.
Specifically, but note that I tried various versions and the dev was my build,
npm install koffi
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fkoffi - Not found
npm ERR! 404
npm ERR! 404 '@types/koffi@^3.0.0-dev' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
cd src/koffi
node ../cnoke/cnoke.js
passed
cd src/koffi/test
node ../../cnoke/cnoke.js
node test.js
Fail because "require" is missing. Maybe there is more to it
To get it to work in my package since step 1 fails. To do this use npm link while in src/koffi then use npm link koffi in the app dir. It should put koffi in the types dir and it should be accessible using const koffi = require('koffi');
I used the following code to test and it worked.
const koffi = require('koffi');
// Load the shared library
const lib = koffi.load('user32.dll');
// Declare constants
const MB_OK = 0x0;
const MB_YESNO = 0x4;
const MB_ICONQUESTION = 0x20;
const MB_ICONINFORMATION = 0x40;
const IDOK = 1;
const IDYES = 6;
const IDNO = 7;
// Find functions
const MessageBoxA = lib.func('__stdcall', 'MessageBoxA', 'int', ['void *', 'str', 'str', 'uint']);
const MessageBoxW = lib.func('__stdcall', 'MessageBoxW', 'int', ['void *', 'str16', 'str16', 'uint']);
let ret = MessageBoxA(null, 'Do you want another message box?', 'Koffi', MB_YESNO | MB_ICONQUESTION);
if (ret == IDYES)
MessageBoxW(null, 'Hello World!', 'Koffi', MB_ICONINFORMATION);
The text was updated successfully, but these errors were encountered: