数组个数
#ifndef ARRAYSIZE
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
#endif

获得结构体首地址
#define CONTAINING_RECORD(address, type, field) ((type *)( \
(PCHAR)(address) - \
(ULONG_PTR)(&((type *)0)->field)))
eg:ScanMessage = CONTAINING_RECORD(Overlapped, SCAN_MESSAGE, Overlapped);

获得距离结构体首地址的偏移
#define FIELD_OFFSET(type, field) ((LONG)(LONG_PTR)&(((type *)0)->field))
eg:FIELD_OFFSET(SCAN_MESSAGE, Overlapped)

posted on 2017-09-27 13:59  CrisCzy  阅读(296)  评论(0编辑  收藏  举报