C语言中union REGS问题

来源:百度知道 编辑:UC知道 时间:2024/06/29 02:58:04
在C语言中,union REGS结构体是怎么定义的,还有它一般是用在哪方面问题上的。希望大家能给我点详细的介绍.谢谢!!!

VC 没有 union REGS 结构体。
老 TC 的 dos.h 里有。用在基本设备,例如鼠标器等。

例如
#include <dos.h>
void GetMouseStatus(int *button,int *x,int *y)
{
union REGS m, o;
m.x.ax=3;
int86(0x33,&m,&o);
*button=o.x.bx &7; //gets only first 3 bits
*x=o.x.cx;
*y=o.x.dx;
}

//... 查鼠标输入
switch (*button) {
case 1: //button==001, bit 0
//左 鼠标健 按下
break;
case 2: //button==010, bit 1
//右 鼠标健 按下
break;
case 4: //button==100, bit 2
//中 鼠标健 按下
break;
//combine bit patterns to test multiple buttons
//ie, to test left and right buttons, test binary 011, or 3 dec.
}

过时的技术,不必学。