效果如下图

部分代码如下所示:

const electron = require('electron');
const path = require("path");
const koffi = require('koffi');
const lib = koffi.load('user32.dll');
const MessageBoxW = lib.func('__stdcall', 'MessageBoxW', 'int', ['void *', 'str16', 'str16', 'uint']);

(async function () {

    electron.ipcMain.handle("showMessageBox", (event, title, message) => {
        MessageBoxW(null, message, title, 0x20);
    })

    await electron.app.whenReady();

    const win = new electron.BrowserWindow({
        width: 300,
        height: 300,
        webPreferences: {
            nodeIntegration: true,
            contextIsolation: true,
            preload: path.join(__dirname, 'preload.js'),
        },
    })
    await win.loadFile(path.join(__dirname, 'index.html'))
})().catch(console.error);