LOWORD, HIWORD, LOBYTE, HIBYTE宏解析

在对一个进程的通信部分做分析时反复遇到了这四类函数,特做此记录。

LOWORD:取32位数的低16位

HIWORD:取32位数的高16位

LOBYTE:取16位数的低8位

HIBYTE:去16位数的高8位

ps:LOBYTE、HIBYTE应用于32位数时,会取32位数后16位数的高低8位。

官方说明

LOWORD macro

Retrieves the low-order word from the specified value.

Syntax

C++

WORD LOWORD(
   DWORD dwValue
);

Parameters

dwValue

The value to be converted.

Return value

Type: WORD

The return value is the low-order word of the specified value.

LOBYTE macro

Retrieves the low-order byte from the specified value.

Syntax

C++

BYTE LOBYTE(
   WORD wValue
);

Parameters

wValue

The value to be converted.

Return value

Type: BYTE

The return value is the low-order byte of the specified value.

随便编段代码来验证:

#include "stdafx.h"
#include<stdio.h>
#include<Windows.h>


int _tmain(int argc, _TCHAR* argv[])
{
	int a = 258;   // 0000 0001 0000 0010
	int b = 65539; // 0000 0000 0000 0001 0000 0000 0000 0011

	printf("lobyte_a:%d\n",LOBYTE(a));
	printf("hibyte_a:%d\n",HIBYTE(a));
	printf("loword_b:%d\n",LOWORD(b));
	printf("hiword_b:%d\n",HIWORD(b));

	return 0;
}

 输出结果:

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值