回 帖 发 新 帖 刷新版面

主题:(求助)高手过来看看~~

高手帮我看看~这是个发光二极管点亮和熄灭的程序.这个是Borland C编的,在win98里可以实现功能,在win2000里就不行啦,好像是outportb()这个函数用不了,能帮忙看看找个能在win2000里实现的函数吗?

#include <string.h>
#include <ctype.h>
#include <dos.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <stdarg.h>
#include <bios.h>
#include <time.h>
#include <conio.h>
#include <process.h>
#include <fcntl.h>


#define  OUTPORT_BASE           0x283     /// address of ISA port ///

#define  ESC                    0x1b                  /* Define the escape key        */

main()
{
  unsigned char key_in=0;

  outportb(OUTPORT_BASE,0xff);  /// LED CLOSE ///

  do
    {
     key_in=0;
     if(kbhit()) key_in=getch();

     if (key_in == ESC)
       {
        outportb(OUTPORT_BASE,0xff);
       }

     if (key_in == '1')
       {
        printf("  Led op.\n\n");
        outportb(OUTPORT_BASE,0x00);
       }

     if (key_in == '0')
       {
        printf("  Led close.\n\n");
        outportb(OUTPORT_BASE,0xff);
       }

    } while (key_in != ESC) ;

clrscr();
exit(0);
}

回复列表 (共3个回复)

沙发

outputb对应的函数为_outp。使用时需要<conio.h>头文件。建议使用_outp,而不是使用outp。因为_outp在Debug和Release都可以使用,而outp只能用于Release设置。    
    但是以上方法只适用于Win9x,在Windows NT/2000下任何硬件I/O操作均需要通过设备启动程序。你可以借助DDK(http://www.microsoft.com/ddk)编写设备驱动程序。你也可以购买现成的软件,如http://zealsoft.nease.net/cn/ntport/。

板凳

有没有好点地写DDK的书,介绍一下!~~谢谢啦!!

3 楼

最好的书就是 DDK Documentation 看你肯不肯去静下新读了。

我来回复

您尚未登录,请登录后再回复。点此登录或注册