#include<stdio.h>
#include<stdlib.h>
#include<dos.h>
#include<conio.h>
#define Key_DOWN 80
#define Key_UP 72
#define Key_A 30
#define Key_B 48
#define Key_C 46
#define Key_Q 18
#define Key_ENTER 28
main()
{
int y;
char ky,ch;
window(7,8,19,15);
textbackground(13);
textcolor(RED);
clrscr();
window(8,9,18,14);
textbackground(1);
textcolor(RED);
clrscr();
gotoxy(3,3);
cprintf("Q:quit\r\n");
gotoxy(3,4);
cprintf("A:dir\r\n");
gotoxy(3,5);
cprintf("B:dir/p\r\n");
gotoxy(3,6);
cprintf("C:dir/w\r\n");
do
{
ky=key();
switch(ky)
{
case Key_A:
{
y=12;
ky=Key_ENTER;
}
break;
case Key_B:
{
y=13;
ky=Key_ENTER;
}
break;
case Key_C:
{
y=14;
ky=Key_ENTER;
}
break;
case Key_Q:
{
y=11;
ky=Key_ENTER;
}
break;
case Key_DOWN:
if(y<13)
{
downbar(y);
y++;
}
break;
case Key_UP:
if(y>10)
{
upbar(y);
y--;
}
break;
}
}while(ky!=Key_ENTER);
switch(y)
{
case 11:
ch='%';
break;
case 12:
{
systen("dir");
getch();
}
case 13:
{
systen("dir/p");
getch();
}
case 14:
{
systen("dir/w");
getch();
}
break;
}
int key()
{
union REGS rg;
rg.h.ah=0;
int86(0x16,&rg,&rg);
return rg.h.ah;
}
Struct WORDREGS
{
unsigned int ax,bx,cx,dx,si,di,cflag,flags;
}
Struct BYTEREGS
{
unsigned char al,ah,bl,bh,cl,ch,dl,dh;
}
union REGS
{
Struct WORDREGS x;
Struct BYTEREGS h;
}
upbar(int y)
{
int i;
typedef struct texel_struct
{
unsigned char ch;
unsigned char attr;
}texel;
texel t;
for(i=9;i<=17;i++)
{
gettext(i,y,i,y,&t);
t.attr=0x1f;
puttext(i,y,i,y,&t);
gettext(i,y+1,i,y+1,&t);
t.attr=0x4f;
puttext(i,y+1,i,y+1,&t);
}
gotoxy(3,y+1);
return;
}
downbar(int y)
{
int i;
typedef struct texel_struct
{
unsigned char ch;
unsigned char attr;
}texel;
texel t;
for(i=9;i<=17;i++)
{
gettext(i,y,i,y,&t);
t.attr=0x1f;
puttext(i,y,i,y,&t);
gettext(i,y-1,i,y-1,&t);
t.attr=0x4f;
puttext(i,y-1,i,y-1,&t);
}
gotoxy(3,y+1);
return;
}
}
完整函数是这样的~~~~