javascript 如何从javascript调用dll中的方法?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7023820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 22:43:27  来源:igfitidea点击:

How to call the methods in a dll from javascript?

c#javascriptdll

提问by Kai

I created a c# class library. I need to to call a method in the library file javascript using the dll.The javascript will be embedded in a web page already created. The dll will be on the client machine. Can someone help?
Ps:the method returns a boolean

我创建了 ac# 类库。我需要使用dll调用库文件javascript中的方法。javascript将嵌入到已经创建的网页中。dll 将在客户端计算机上。有人可以帮忙吗?
Ps:该方法返回一个布尔值

More details: Actually the website is a virtual web conferencing software in which each one has a particualr avatar. I have to detect whether a particular software(needed for making video calls) is installed in the user's system.If it is installed i have to indicate that by showing some special symbols on his avatar.I made a c# class library which returns "true" if the software is installed in the system.Now i have to embed this in the virtual conferencing web software

更多细节:实际上该网站是一个虚拟网络会议软件,其中每个人都有一个特定的头像。我必须检测用户的系统中是否安装了特定的软件(进行视频通话所需)。如果安装了,我必须通过在他的头像上显示一些特殊符号来表明这一点。我制作了 ac# 类库,它返回“true” “如果系统中安装了该软件。现在我必须将其嵌入到虚拟会议网络软件中

I am new to c# and javascript programming!

我是 C# 和 javascript 编程的新手!

采纳答案by Ulrik Magnusson

回答by Yak S.D.

Possible solution:

可能的解决方案:

You need to register your dll at the destination computer. Than in js you need to create ActiveX object with the same registered name

您需要在目标计算机上注册您的 dll。比在 js 中您需要创建具有相同注册名称的 ActiveX 对象

var ObjFromDll = new ActiveXObject("DllRegisteredName");

and call it's method.

并调用它的方法。

var anyResult = ObjFromDll.MyMethod()