web前端调用dll,需要从浏览器调用客户端DLL

I got requirement from client that when any user swipe their card then their details should be capture in web page automatically on client side. However same we are doing in IE by creating ActiveX control in C#. Card service provider install their DLL on client side and from ActiveX control, we can call their DLL and get details.

But now client want the same operation in multiple browser, i.e. Mozilla Firefox and Chrome, which does not support ActiveX control. Can you please give me an idea how it is possible to call client side DLL method from browser?

解决方案

I had to do the exact same thing and I've done it using EdgeJS. You can find the answer at Call Function from DLL loaded in front-end javascript (load dll in clientside javascript) .

At first, I used activex for IE. Then, I had to port it to other browsers. The trick is to marshal functions between V8 and CLR and when the event triggers you send the message to javascript.

The dll returns a delegate function as a receive handler. You initialize the dll with the send handler. I haven't found a method to run the dlls from the browser yet as you do with ActiveX.

It might be that, for security reasons, you might not be able to embed and run dlls in clientside javascript.

The solution in the stackoverflow question is a node process that runs on the client computer that has the Swipe Reader. The client application connects to the node process that runs a websocket server and communicates through websocket messages. I think you can port this on every platform (Win, Unix, MacOS).

Another solution is to build a C# application (windows only if you use .NET, all platforms if you only use the CoreCLR) that listens to swipes and triggers an event to send the data on all connected websockets.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值