peekb

函数名: peekb

功 能: 检查存储单元

用 法: char peekb (int segment, unsigned offset);

segment为段基地址,offset偏移地址。

程序例:

#include <stdio.h>

#include <conio.h>

#include <dos.h>

int main(void)

{

int value = 0;

printf("The current status of your keyboard is:\n");

value = peekb(0x0040, 0x0017);

if (value & 1)

printf("Right shift on\n");

else

printf("Right shift off\n");

if (value & 2)

printf("Left shift on\n");

else

printf("Left shift off\n");

if (value & 4)

printf("Control key on\n");

else

printf("Control key off\n");

if (value & 8)

printf("Alt key on\n");

else

printf("Alt key off\n");

if (value & 16)

printf("Scroll lock on\n");

else

printf("Scroll lock off\n");

if (value & 32)

printf("Num lock on\n");

else

printf("Num lock off\n");

if (value & 64)

printf("Caps lock on\n");

else

printf("Caps lock off\n");

return 0;

}

相关词汇