如何运行本地Windows应用程序并将输出通过管道传输到浏览器 [英] How can I run a local Windows Application and have the output be piped into the Browser

查看:245
本文介绍了如何运行本地Windows应用程序并将输出通过管道传输到浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Windows应用程序(.EXE文件用C编写,并使用MS-Visual Studio构建),该应用程序将ASCII文本输出到stdout。我希望增强ASCII文本,使其包含带有一些链接的有限HTML。我想调用此应用程序(.EXE文件)并获取该应用程序的输出,并将其通过管道传输到浏览器中。这不是一次性的事情,每个新的网页都是本地应用程序的另一次运行!

I have Windows Application (.EXE file is written in C and built with MS-Visual Studio), that outputs ASCII text to stdout. I’m looking to enhance the ASCII text to include limited HTML with a few links. I’d like to invoke this application (.EXE File) and take the output of that application and pipe it into a Browser. This is not a one time thing, each new web page would be another run of the Local Application!

下面的HTML / java-script应用程序已为我执行应用程序,但输出已进入DOS Box窗口,而不是将其通过管道传输到浏览器。我想更新此HTML应用程序,以使浏览器能够捕获该文本(使用HTML进行了增强)并在浏览器中显示。

The HTML/java-script application below has worked for me to execute the application, but the output has gone into a DOS Box windows and not to pipe it into the Browser. I’d like to update this HTML Application to enable the Browser to capture that text (that is enhanced with HTML) and display it with the browser.

<body>
 <script>
 function go() {
   w = new ActiveXObject("WScript.Shell");
   w.run('C:/DL/Browser/mk_html.exe');
   return true;
   }

 </script>

 <form>
   Run My Application (Window with explorer only)
     <input type="button" value="Go" 
     onClick="return go()">
</FORM>

</body>


推荐答案

您已经在使用WScript启动了,它也可以读取 StdOut

Your already using WScript to launch, it can also read StdOut.

<html>
<head>
<script type="text/javascript">
function foo() {
 var WshShell = new ActiveXObject("WScript.Shell");
 var oExec = WshShell.Exec("ipconfig.exe");
 var input = "";

 while (!oExec.StdOut.AtEndOfStream) {
         input += oExec.StdOut.ReadLine() + "<br />";
 }

 if (input)
  document.getElementById("plop").innerHTML = input;
}
</script>
</head>
<body onload="foo();">
 <code id="plop"></code>
</body>
</html>

这篇关于如何运行本地Windows应用程序并将输出通过管道传输到浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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