C 中的特权指令
我在使用 C 时遇到了一些问题。我正在尝试在 VS 2010 Ultimate 中的 Windows 7 Professional x64 中对并行端口进行编程。 由于我没有并行端口,因此我使用 USB-> 并行端口的转换器,并且 Windows 正确安装了驱动程序。 我在并行连接器的末端焊接了 8 个 LED,当我将 USB 连接到计算机时,它们都工作正常。 现在,我想通过用 C 编写的程序来控制并行端口,即:
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <Windows.h>
/********************************************/
/*This program set the parallel port outputs*/
/********************************************/
void main (void)
{
//clrscr(); /* clear screen */
_outp(0x378,0xff); /* output the data to parallel port */
getch(); /* wait for keypress before exiting */
}
程序被编译并运行,但我收到一条错误消息:
Unhandled exception at 0x00f313a5 in portovi.exe: 0xC0000096: Privileged instruction.
我已读到端口 IO 在 Windows NT 机器中被禁用,并且您需要一个特定的司机来做这件事。有什么办法解决吗?
I'm having some problems with C. I am trying to program a parallel port in Windows 7 Professional x64 in VS 2010 Ultimate.
Since I do not have a parallel port, I'm using a converter from USB->Parallel and Windows installed the drivers correctly.
I've soldered 8 LED-s on the end of the parallel connector and they are all working fine when I connect the USB into the computer.
Now, I would like to control the parallel port via my program written in C which is:
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <Windows.h>
/********************************************/
/*This program set the parallel port outputs*/
/********************************************/
void main (void)
{
//clrscr(); /* clear screen */
_outp(0x378,0xff); /* output the data to parallel port */
getch(); /* wait for keypress before exiting */
}
The program gets compiled and runs but I get an error message:
Unhandled exception at 0x00f313a5 in portovi.exe: 0xC0000096: Privileged instruction.
I have read that port IO is disabled in windows NT machines and that you need a specific driver to do it. Is there any solution to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一些方法可以解决这个问题。例如,请参阅此处。
There are ways around this. See here for instance.
您的 USB-> 并行转换器具有用于创建虚拟并行端口的驱动程序。它实现了 Windows 并行端口 API。它没有实现PC/AT并行端口寄存器级API,即使您被允许写入I/O端口
0x0378
,您也不会在那里找到任何东西。只有系统总线(ISA 或 PCI)上真正的 PC/AT 并行端口才使用该寄存器。Your USB->parallel converter has drivers to create a virtual parallel port. It implements the Windows parallel port API. It does not implement the PC/AT parallel port register-level API, and even if you were permitted to write I/O port
0x0378
, you wouldn't find anything there. Only real PC/AT parallel ports on the system bus (ISA or PCI) use that register.