从网络浏览器运行安装在客户端计算机上的 exe 文件
我有一个用 VB.NET 编写的小 exe 文件,它连接到数据库,获取最后一行并将信息发送到打印机。它只是程序的一小部分,但它使用特殊字体并计算打印机的宽度。
我用 PHP 开发了同样的程序。现在它的几乎所有功能都与基于 Windows 的程序相同。但是网络浏览器的打印结果不能与我使用exe文件得到的结果相同。所以我只想将参数发送到 exe 文件并运行它。 (使用 javascript 调用或其他)Exe 文件位于客户端计算机上,我会知道它的位置。
你能建议我一种方法吗? 我读到这可以使用 dll 或 ocx 实现。
我不熟悉开发浏览器插件。 有这方面的教程或书籍吗? 提前致谢。
I have a small exe file written in VB.NET which connects to database, gets the last row and send the information to the printer. It is just a small part of a program but it uses special font and also calculates the widths for the printer.
I've developed the same program with PHP. Now almost every functionality of it is same wirh the windows based program. But the printing results of the web browser can't be same as I get with the exe file. So I want to just send a paramater to the exe file and run it. (with a javascript call or else) Exe file is on the client machine and I will know where it is the located.
Can you suggest me a way to do that.
I read that this is possible using dll or ocx.
I'm not familiar developing browser plugins.
Is there a tutorial or book for that?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我的机器突然问我网站是否可以下载并运行 exe,我会在对话框完成渲染之前关闭窗口。
这里要做的最简单的事情是修复 php 输出的格式。仅仅因为您可以在客户端上执行 exe 文件,就与您应该执行的含义相差一百万英里。除非您了解并完全控制用户和这些用户正在使用的系统,否则任何与 exe 相关的系统充其量都将是脆弱的,即使您确实拥有这种控制权,它也是一个障碍。
有一些为 php 编写的 pdf 库,可以让您更好地控制输出,包括字体。 Sitepoint 上有一篇这样的库的文章。
或者,您可以将 .NET 应用程序转换为 php 可以与之通信的 Web 应用程序/服务。
If my machine suddenly asked me if it was ok for a website to download and run an exe, I'd have closed the window before the dialog had finished rendering.
The simplest thing to do here would be to fix the formatting of the php's output. Just because you can potentially execute an exe file on the client is a million miles away from meaning you should. Unless you know and have complete control over the users and the systems that those users are working on, any exe related system is going to be brittle at best and even if you do have that control, it's a bodge.
There are pdf libraries written for php that would permit you better control over your outputs, including fonts. There's a write up of one such library over at Sitepoint.
Alternatively, you could probably turn your .NET app into a web app/service that your php could communicate with.
开发一个浏览器插件来做你不想做的事情并不是非常困难;我必须同意 JHolyhead 的观点,如果可以的话,最好避免这样做,因为存在一些重大的安全考虑。
您需要了解一些 C++,并且可以使用 FireBreath 框架来编写可在所有平台上运行的插件。启动进程可以使用 CreateProcessEx 来完成,您将遇到的主要挑战是,当您在启用了 UAC 的 vista/win7 上(由于保护模式)时,该进程将以低完整性模式在 IE 中启动。最简单的解决方法是将站点添加到受信任站点列表中,但是有一些方法可以使其可以在中等完整性(正常非提升)模式下启动该进程。
如果你懂C++并且有一些windows开发经验,这会很容易;如果不这样做,可能会有点棘手。如果还有其他选项(不需要您安装浏览器插件),您最好遵循它们。然而,一个基本的 FireBreath 插件可以在大约 20 分钟内组装完成(有视频教程)。
Developing a browser plugin to do what you wan't isn't terribly difficult; I have to agree with JHolyhead that it'd be better to avoid doing this if you can, because there are some siginificant security considerations.
You'd need to know some C++ and you could use the FireBreath framework to write a plugin that would work on all platforms. Launching a process can be done using CreateProcessEx, and the main challenge you'll run into is that the process will be launched in low integrity mode in IE when you're on vista/win7 w/ UAC enabled (due to protected mode). The easiest fix for this is to just add the site to your list of trusted sites, but there are some ways to make it posible to launch the process is medium integrity (normal non-elevated) mode.
If you know C++ and have some experience with windows development, this would be very easy; if you don't, it might be a bit trickier. If there are other options (that dont' require you to install a browser plugin) you'd probably be better off following them. However, a basic FireBreath plugin can be thrown together in about 20 minutes (there are video tutorials).