使用 C++ 创建 Windows 7 虚拟并行
我正在开发一个应用程序,它将 I/O 从设备 A 的并行端口重定向到设备 B 的并行端口。两个设备通过以太网(LAN、WAN、互联网等)连接。
设备 A 连接有一个物理并行端口,但设备 B 是一台没有并行端口的机器。这就是让我在设备 B 上模拟并行端口的原因,这样 Windows 就会认为它有一个并行端口,并以与硬件上的并行端口相同的方式工作,例如,它会自动检测何时设备连接到并行端口,以便可以安装该设备的驱动程序。
如果任何硬件连接到设备 A 上的并行端口,则 I/O 将重定向到设备 B 上的并行端口以及设备 B 上的 Windows 认为某些硬件已连接到设备 B 自己的并行端口,即 Windows 不知道该硬件实际连接在世界的哪个位置; Windows 只是误以为硬件直接连接到设备 B。
我的问题是关于模拟部分。如何用 C++ 为 Windows 7 编写并行端口仿真器,以便欺骗 Windows 认为它具有真实/硬件并行端口?
一个相关的问题可能是 Windows 如何检测硬件及其持续变化,例如,当某些硬件连接到计算机的并行端口时。
程序流程如下。
- 从设备A并行端口读取数据。
- 将该数据写入设备 A 套接字,该套接字将其发送到设备 B 套接字。
- 从设备 B 套接字读取数据。
- 将该数据写入设备 B 并行端口,这使 Windows 认为某些硬件已连接到它。
注意:我只模拟并行端口,即并行到并行重定向。不允许使用设备 B 上的其他端口。这是此应用程序的要求。
到目前为止我所做的部分是用 C++ 编写了一个程序,该程序分别从并行端口读取数据并向并行端口写入数据。
如果您知道通过以太网(LAN、WAN、互联网等)进行并行端口到并行端口重定向的更好方法,也请告诉我。
I am developing an application which would redirect i/o from parallel port of, say, device A to the parallel port of device B. The two devices are connected on ethernet (LAN, WAN, internet, etc.).
Device A has a physical parallel port attached to it but device B is a machine with no parallel port on it. This is what makes me emulate a parallel port on device B such that windows thinks that it has a parallel port and works in the very manner with it as it works with parallel ports on hardware e.g. it auto detects when a device gets attached to the parallel port so that a driver for that device can be installed.
If any piece of hardware gets attached to the parallel port on device A the i/o is redirected to the parallel port on device B and the Windows on device B thinks that some hardware got attached to device B's own parallel port i.e. Windows doesn't know where in the world the hardware actually got attached; Windows just got fooled into thinking that the hardware is attached directly to device B.
My question is about the emulation part. How do I write a parallel port emulator in C++ for Windows 7 such that I fool Windows into thinking that it has a real/hardware parallel port?
A related question can be how does windows detect the hardware and on going changes in it e.g. when some hardware gets connected to the parallel port of a computer.
The program flow would be as follows.
- Read data from device A's parallel port.
- Write that data to device A's socket which sends it over to device B's socket.
- Read data from device B's socket.
- Write that data to device B's parallel port which makes windows think that some hardware got connected to it.
NB: I am to emulate a parallel port only i.e. parallel to parallel redirection only. No use of other ports on device B is allowed. That is a requirement for this application.
The part I've done so far is that I have written a program in C++ which reads and writes data from and to the parallel port respectively.
Please also let me know if you know of a better approach of parallel port to parallel port redirection over ethernet (LAN, WAN, internet, etc.).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 Windows 上搜索 LPT 虚拟化时偶然发现了这个问题。
我知道这个已经很旧了,不幸的是我也没有直接的答案,但我想我会分享我迄今为止发现的可以帮助您入门的内容:
Stumbled upon this question in my own search for LPT virtualization on windows.
I know this one is old and unfortunately I don't have an direct answer to the it either, but I thought I'll share what I've found so far that could help you getting started: