当前位置: 首页 > news >正文

electron笔记无边框窗口、DLL调用、DLL函数返回指针

无边框

const win = new BrowserWindow({width: 1290,height: 736,minHeight: 736,minWidth: 1040,maxHeight: 736,maxWidth: 1290,frame: false, // 无边框webPreferences: {// preload: process.env.WEBPACK_DEV_SERVER_URL ? __dirname + '/preload.js' : 'app://./preload.js',// devTools: true,// Use pluginOptions.nodeIntegration, leave this alone// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more infonodeIntegration: true,contextIsolation: false}})

窗口鼠标拖拽移动

ipcMain.handle("window-move-open", (event, canMoving) => {let winStartPosition = { x: 0, y: 0 };let mouseStartPosition = { x: 0, y: 0 };const currentWindow = BrowserWindow.getFocusedWindow();const currentWindowSize = currentWindow.getSize();if (currentWindow) {if (canMoving) {const winPosition = currentWindow.getPosition();winStartPosition = { x: winPosition[0], y: winPosition[1] };mouseStartPosition = screen.getCursorScreenPoint();if (movingInterval) {clearInterval(movingInterval);}movingInterval = setInterval(() => {if (!currentWindow.isDestroyed()) {if (!currentWindow.isFocused()) {clearInterval(movingInterval);movingInterval = null;}const cursorPosition = screen.getCursorScreenPoint();const x =winStartPosition.x + cursorPosition.x - mouseStartPosition.x;const y =winStartPosition.y + cursorPosition.y - mouseStartPosition.y;currentWindow.setBounds({x: x,y: y,width: currentWindowSize[0],height: currentWindowSize[1],});}}, 10);} else {clearInterval(movingInterval);movingInterval = null;}}});

调用dll
nodejs调用dll依赖ffi模块,如何安装ffi依赖?
推荐文章地址:https://blog.csdn.net/qq_28218253/article/details/121643328
需要注意的问题:
1.首先要判断dll是32位还是64位?

桌面左下角搜索,输入vs,选择vs开发者命令行工具, 输入dumpbin /headers XXX.dll,在这里插入图片描述
如果是x86 32 bit,则为32位,反之是64

2.根据dll是32位还是64位,选择对应的nodejs版本以及electron。
推荐文章地址:https://blog.csdn.net/qq_28218253/article/details/121643328
3.安装windows-build-tools出现卡住的问题?
推荐文章地址:https://blog.csdn.net/Ajucy/article/details/130380278

如何调用dll

const dllPath = process.cwd()+'\\5.6.0.8_64.dll';
let strPtr = refArray('uchar',16)
const library = ffi.Library(dllPath,{DyInit: ['int',[]],DyGetPushStreamUrl:[ref.refType(strPtr),[]],DyUnInit: ['int',[]],DyGetVersion: [ref.refType(strPtr),[]],
})let res =  library.DyGetVersion()console.log(res.toString())

dll函数返回指针数据
推荐文章地址:https://blog.csdn.net/RuanEmpty/article/details/115692244

http://www.lryc.cn/news/157411.html

相关文章:

  • 递归算法学习——黄金矿工,不同路径III
  • pg 创建分区表 --chatGpt
  • 长城网络靶场,第一题笔记
  • el-form表单中不同数据类型对应的时间格式化和校验规则
  • Python代码雨
  • java.util.Optional
  • 微服务--Seata(分布式事务)
  • 发光太阳聚光器的蒙特卡洛光线追踪研究(Matlab代码实现)
  • (涨知识)-圣诞灯串类产品出口都需要做哪些认证?
  • ROS地图/像素坐标描点调试【Python源码实现】
  • 2023年7月京东笔记本电脑行业品牌销售排行榜(京东数据平台)
  • 用户忠诚度:小程序积分商城的用户保持方法
  • [前端] 使用lerna version更新版本号
  • winform嵌入浏览器 webView2
  • stm32---用外部中断实现红外接收器
  • Filter过滤器及HttpServletRequest和HttpServletResponse
  • 02-打包代码与依赖
  • Kotlin(五) 循环语句
  • 数字孪生产品:数字化时代的变革引擎
  • 对接西部数据Western Digital EDI 系统
  • ClickHouse进阶(十):Clickhouse数据查询-4
  • FPGA原理与结构——FIFO IP核的使用与测试
  • ABB CMA120 3DDE300400面板
  • 【代码随想录day25】动态规划:01背包理论基础
  • Python Opencv实践 - 轮廓检测
  • c#保留两位小数
  • [machineLearning]非监督学习unsupervised learning
  • C语言深入理解指针(非常详细)(四)
  • 知识库建设:从0到1搞定知识库建设的方法论分享
  • SpringBoot+Vue 的留守儿童系统的研究与实现,2.0 版本,附数据库、教程