我在win98下用C语言编了一段代码实现对并口的操作,程序如下:#include "stdio.h"
#include "dos.h"
main()
{
int porta=0x378;
int portb=0x379;
int portc=0x37A; unsigned int ina,inb,inc; ina=inportb(porta);
inb=inportb(portb);
inc=inportb(portc); printf("the porta value is:%d\n",ina);
printf("the portb value is:%d\n",inb);
printf("the portc value is:%d\n",inc); if (inb==126)
outportb(porta,128);
else if(inb==62)
outportb(porta,192);
else
outportb(porta,0);
}
但是在windows 2000/NT 下对端口进行了保护,不能直接对端口进行操作,请问如何在windows 2000/NT 下用VC++编程实现上面的程序所实现的对并口的读写操作功能,我初学VC++,用createfile()和readfile()等函数也用不好,如果那位大侠能给一个用VC++对并口进行操作的实例,小弟我将非常感激。
#include "dos.h"
main()
{
int porta=0x378;
int portb=0x379;
int portc=0x37A; unsigned int ina,inb,inc; ina=inportb(porta);
inb=inportb(portb);
inc=inportb(portc); printf("the porta value is:%d\n",ina);
printf("the portb value is:%d\n",inb);
printf("the portc value is:%d\n",inc); if (inb==126)
outportb(porta,128);
else if(inb==62)
outportb(porta,192);
else
outportb(porta,0);
}
但是在windows 2000/NT 下对端口进行了保护,不能直接对端口进行操作,请问如何在windows 2000/NT 下用VC++编程实现上面的程序所实现的对并口的读写操作功能,我初学VC++,用createfile()和readfile()等函数也用不好,如果那位大侠能给一个用VC++对并口进行操作的实例,小弟我将非常感激。
我用createfile()打开并口LPT1是成功了,接着用readfile()读并口时怎么也读不了,用writefile()写并口时也出错了,是不是还需要对并口进行一些配置?我初学VC++,对这些还不太熟悉,能不能讲具体点,该如何使用这三个函数对并口进行操作?