The macro expects two bytes as its parameters:
WORD MAKEWORD(
BYTE bLow,
BYTE bHigh
);
Its defined in Windef.h
as :
#define MAKEWORD(a,b) ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8)))
It basically builds a 16 bits words from two 1 bytes word (and doesn't look very portable)
The binary representation of the number 2 with 1 byte (a WORD) is :
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
If we take the concatenate two of those bytes as in MAKEWORD(2,2)
, we get:
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
Which is 512 + 2 = 514 : live demo.
The only real life example of this particular macro is in the Initialization of Winsock, to generate the versioning word expected by WSAStartup
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…