从Javascript调用DLL方法 [英] Call DLL methods from Javascript

查看:261
本文介绍了从Javascript调用DLL方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从javascript调用一个dll的方法。



我遵循这篇文章使用c#创建activex对象



由于activeX仅在IE中工作,我应该可以从FireFox或Chrome中的javascript调用这些方法吗?



我已经有一个使用ActiveX对象调用Dll方法的应用程序,但它在IE



有什么可能的方式使我的应用程序浏览器独立吗?



更新



我使用Jquery异步AJAX和webservice调用dll方法:

  var to_return = $ .ajax({
type:POST,
url:Default.aspx / CallMe,// CallMe是WebService方法
data:{ },//参数传递
async:false,
contentType:application / json; charset = utf-8,
dat aType:json,
});

alert(to_return.responseText);

如果 CallMe()返回一个字符串,它会将其提醒为 {d:True} 其中True是从CallMe返回的字符串。



如何才能从还有,如果webservice的 CallMe()方法返回该DLL中存在的类的对象?
如何在JavaScript中检索该对象?和
我可以使用该返回的对象调用该类的方法吗?



请帮助。

解决方案

您不能在浏览器中执行dll方法(这是为了安全起见)。

为了在浏览器中执行一些编译代码,您必须使用插件



ActiveX只是在IE中实现浏览器插件的一种方法。所有其他浏览器使用不同的插件接口。

那么如果用户将在浏览器中安装你的插件 - 这个插件可以从JS中获得,你可以使用它在dll中执行一些功能。


I want to call a methods of a dll from javascript.

I followed this article Creating activex objects with c#

Since activeX works in IE only, how should I be able to call those methods from javascript in FireFox or Chrome?

I am already having an application which uses ActiveX object to call Dll Methods, but it works in IE only.

Is there any possible way that will make my application browser Independent?

UPDATED

I used Jquery async AJAX and webservice to call dll methods:

var to_return = $.ajax({
         type: "POST",
         url: "Default.aspx/CallMe", //CallMe is WebService method
         data: "{}", // parameter to pass
         async: false,
         contentType: "application/json; charset=utf-8",
         dataType: "json",
     });

     alert(to_return.responseText);

If CallMe() returns a string it is alerting it as {"d":"True"} where "True" is the string returned from CallMe.

How will I able to get only returned string from it?

Also, if CallMe() method of webservice returns an Object of a class present in that DLL? How can I retrieve that object in JavaScript? and Will I be able to call methods of that class using that returned object?

Please Help.

解决方案

You can't just execute a dll method in browser (this is done for security reasons).
In order to execute some compiled code in browser you will have to use a plugin

ActiveX is just a method of implementing browser plugin in IE. All other browsers use different plugin interfaces.
Then if user will install your plugin in browser - this plugin will be available from JS and you can use it to execute some function in dll.

这篇关于从Javascript调用DLL方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆