将数据从HTML5应用程序传输到在客户端上下文下运行的本机应用程序

问题描述 投票:3回答:2

我有两个应用程序,App1和在Windows7客户端上下文中运行的App2。

App1: List files. and allows user to select a file and trigger load file to App2. This is HTML5 application ( Angular 2) hosted in IIS.
App2: Allows to view the files. Native C++ application. 

我想将特定的选定文件详细信息从App1发送到App2。我尝试过以下callup选项:

  1. ActiveX控件: App2是一个activeX控件,App1基本上调用一个ASP页面,该页面在内部运行一个java脚本来加载App2 ActiveX并传输详细信息。但这只适用于IE。没有定期修复其他Web浏览器。
  2. 网络插座: App2托管websocket服务器,App1 angular app调用Web套接字API将数据传输到App1。这迫使我在客户机中托管网络服务器代码,这不是很好的IMO。

有哪些其他选项可用于将数据从HTML5应用程序传输到在客户端上下文下运行的本机应用程序?

c++ angularjs html5 google-chrome native
2个回答
0
投票

您可以使用Chrome Native Messaging API。请参见此处的示例:https://chromium.googlesource.com/chromium/src/+/master/chrome/common/extensions/docs/examples/api/nativeMessaging

试试这个例子:(你需要为这个例子安装python才能工作。)

  1. 从上面的链接下载示例
  2. 使用install_host.bat注册主机
  3. 在chrome:// extensions /中启用开发人员模式,并从/ app目录加载解压缩的扩展名
  4. 转到chrome:// apps /并启动Native Messaging Example应用程序
  5. 按连接

如果一切顺利,该应用将启动,您将能够在Chrome和应用之间交换消息。

enter image description here

现在用app2.exe替换native-messaging-example-host.bat并相应地调整脚本。

希望能帮助到你。 :)


0
投票

从这个answer

你想创建一个Asynchronous Pluggable Protocol Handler

这是registering an Application Protocol的指南。

© www.soinside.com 2019 - 2024. All rights reserved.