Open wuyuedefeng opened 4 years ago
electron中文资料:
electron与c++/.net通信 让electron-app支持带参数的命令行调用 环信实操 | 使用electron进行跨平台桌面开发 在electron中调用C++动态库的经验总结
直接调用系统动态库
- demo
var ref = require('ref'); var ffi = require('ffi');
var voidPtr = ref.refType(ref.types.void); var stringPtr = ref.refType(ref.types.CString);
var user32 = ffi.Library('user32.dll', { EnumWindows: ['bool', [voidPtr, 'int32']], GetWindowTextA : ['long', ['long', stringPtr, 'long']] });
windowProc = ffi.Callback('bool', ['long', 'int32'], function(hwnd, lParam) { var buf, name, ret; buf = new Buffer(255); ret = user32.GetWindowTextA(hwnd, buf, 255); name = ref.readCString(buf, 0); console.log(name); return true; });
user32.EnumWindows(windowProc, 0);
编译app
package.json
无法正常使用一些node库,需重新编译
下载
build时候无法下载,或者下载缓慢electron
更改镜像源electron为淘宝源
webview和主进程之间数据通信