更新时间:2024-05-21 17:23
WORD,是编程语言中的一种数据类型,是指无符号的短整型,且占2个字节。
微软的定义:
typedef unsigned short WORD;
说明WORD是无符号的短整型,且占2个字节
WORD DWORD BYTE相互转换:
DWORD 4个字节
WORD 2个字节
BYTE 1个字节
(1) DWORD--->WORD
[cpp]
DWORD dw=0; WORD hW=HIWORD(dw); WORD lW=LOWORD(dw);
(2)WORD--->DWORD
[cpp]
DWORD dw=0; WORD hW=HIWORD(dw); WORD lW=LOWORD(dw); dw=MAKELONG(lW,hW);
(3) WORD---->BYTE
[cpp]
WORD word=0; BYTE hb=HIBYTE(word); BYTE lb=LOBYTE(word);
(4)BYTE------>WORD
[cpp]
WORD word=0; BYTE hb=HIBYTE(word); BYTE lb=LOBYTE(word); word = MAKEWORD(lb,hb);
[cpp]
综合例子:
[cpp]