aardio 里网页调用原生 DLL 相对简单一些。
嵌入 Electron 组件调用 DLL :
---------------------------
import
electron.app;
var theApp =
electron.app();
theApp.html = /**
<script>
aardio = require("aardio");
aardio.msgBox("内容","标题");
</script>
**/
theApp.external = {
msgBox = function(text,caption){
::User32.MessageBox(theApp.hwndChrome,text,caption,0)
}
}
theApp.start("/res/index.html");
win.loopMessage();
WebView2 调用 DLL :
---------------------------
import win.ui;
var winform = win.form(text="WebView2")
import web.view;
var wb = web.view(winform);
wb.external = {
msgBox = function(text,caption){
::User32.MessageBox(winform.hwnd,text,caption,0)
}
}
wb.html = /**
<script> aardio.msgBox("内容","标题");</script>
**/
winform.show();
win.loopMessage();
JavaScript 直接调用 DLL :
---------------------------
import win.ui;
var winform = win.form(text="JS 直接调用 WinAPI")
import web.blink.form;
var mb = web.blink.form(winform);
web.blink.export(
user32 = ::User32;//导出 DLL 对象为 JS 全局变量
form = winform; //窗口对象也可以导出为 JS 变量
blink = mb; //mb 自己也可以导出为 JS 变量
);
mb.html = /**
<a href='javascript:
user32.MessageBox(0,"JS 直接调用 WinAPI","user32.MessageBox",0)
'>JS 直接调用 WinAPI 函数试一下</a>
**/
winform.show()
win.loopMessage();