How to call user32.dll methods from javascript

I have javascript running in a browser. Is it possible to call a function / method in user32.dll.

This is possible from C # using pInvoke calls. How to do the same in JavaScript?

Thank,

Datte

+1
source share
6 answers

Due to the JavaScript sandbox, you cannot do this without an intermediate level that requires elevated security permissions, such as a Netscape-style browser plug-in (widely supported), an ActiveX control (mostly just IE), or .Net (I assume that this is possible, again, perhaps only IE). In each case, JavaScript will access the control, which in turn will trigger a USER32 request.

, , , Windows, - , .

+10

, ActiveX, .

firefox jsctypes, .
API Jetpack, Firefox 4, JavaScript .

mozilla.org Hello World:

/* Load JS Ctypes Javascript module */
require("chrome").Cu.import("resource://gre/modules/ctypes.jsm");

/* Load windows api dll */
var lib = ctypes.open("user32.dll");

/* Declare the signature of the function we are going to call */
var msgBox = lib.declare("MessageBoxW",
                         ctypes.stdcall_abi,
                         ctypes.int32_t,
                         ctypes.int32_t,
                         ctypes.ustring,
                         ctypes.ustring,
                         ctypes.int32_t);
var MB_OK = 3;

/* Do it! */
var ret = msgBox(0, "Hello world", "title", MB_OK);

/* Display the returned value */
alert("MessageBox result : "+ret);

lib.close();
+4

- (, ... - , ActiveX, IE, , DLL ).

, AJAX #.

0

dll , javascript -? , .

0

- #, JavaScript , , . , , .

0

com-, user32. IE/javascript. DynamicWrapperX ( com, DLL ).

0

All Articles