firemail

标题: js-ctypes [打印本页]

作者: jimu    时间: 2016-1-14 23:56
标题: js-ctypes

js-ctype可以让应用程序和浏览器扩展代码调用用C/C++语言编写的本地代码.

js-ctypes 非常强大,是我们可以摆脱xpcom技术带来的版本兼容性束缚!这里我们先提供一个最简单的例子来说明如何使用ctypes
Components.utils.import("resource://gre/modules/ctypes.jsm");
  varlib = ctypes.open("C:\\WINDOWS\\system32\\user32.dll");
  /*Declare the signature of the function we are going to call */
  varmsgBox = lib.declare("MessageBoxW",
                           ctypes.winapi_abi,
                           ctypes.int32_t,
                           ctypes.int32_t,
                           ctypes.jschar.ptr,
                           ctypes.jschar.ptr,
                           ctypes.int32_t);
  varMB_OK = 0;
  varret = msgBox(0, "Hello world", "title", MB_OK);
lib.close();
项目中的其它使用参考 托盘扩展
更多参考
https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes






欢迎光临 firemail (http://www.firemail.wang:8088/) Powered by Discuz! X3