如何运行本地 Windows 应用程序并将输出通过管道传输到浏览器

发布于 2024-08-30 12:08:10 字数 670 浏览 1 评论 0原文

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

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

<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>

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!

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

清引 2024-09-06 12:08:10
  1. 让可执行文件侦听遵循 HTTP 协议的端口。
  2. 然后让网页使用 JAvascript 向本地端口发出 AJAX 样式的 HTTP 请求。
  3. 可执行文件返回文本。
  4. 网页通过 Javascript 中的 DOM 操作进行自我更新。

是的,这有效。它现在就发生在离我 5 英尺远的另一个隔间里。

  1. Have the executable listen on a port following the HTTP protocol.
  2. Then have the web page make AJAX-style HTTP requests to the local port with JAvascript.
  3. The executable returns text.
  4. The web page updates itself through DOM manipulation in Javascript.

Yes, this works. It is happening 5 feet away from me right now in another cubicle.

风渺 2024-09-06 12:08:10

这称为 CGI

This is called CGI

╰ゝ天使的微笑 2024-09-06 12:08:10

您已经使用 WScript 启动,它还可以读取 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>

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>
古镇旧梦 2024-09-06 12:08:10

让 EXE 创建一个包含 HTML 的临时文件,然后告诉 Windows 在浏览器中打开该临时 HTML 文件会更容易。

It would be easier to have your EXE create a temp file containing the HTML, then just tell Windows to open the temp HTML file in the browser.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文