views:

439

answers:

3

Hello all,

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

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

Thanks,

Datte

+1  A: 

On the client - it is not possible for security reasons (imagine every site could run system commands on your computer... end of the world - maybe possible with an ActiveX, but that's IE only, but then again, the DLL is windows only).

If you want to run it on the server you'll need to go trough AJAX and C#.

Kobi
+5  A: 

Because of the JavaScript sandbox, you can't do it without a middle layer requiring elevated security permissions, such as a Netscape-style browser plug-in (widely supported), ActiveX control (pretty much IE-only), or .Net control (I assume that's possible; again probably IE-only). In each case, the JavaScript would talk to the control, which would in turn make the USER32 call for you.

None of that will work without the user having granted your application elevated permissions, but I'm guessing as you're requiring Windows, this is for some kind of intranet application where that may be possible.

T.J. Crowder
A: 

Run dll methods on the client machine using javascript from a web page? That's what is gonna trigger apocalypse.

Amarghosh