msdn中有一段话:
each structure member after the first is stored on byte boundaries that are either the alignment requirement of the field or the packing size (n), whichever is smaller.
下面使alignment requirement列表:
Primitive data type Alignment 
1)char     byte 
2)short    WORD (2 bytes) 
3)int (equivalent to long on Windows NT)
         DWORD (4 bytes) 
4)long     DWORD 
5)_ _int64 QUADWORD (8 bytes) 
6)float    DWORD 
7)double   QUADWORD 
8)Any pointer type
         DWORD 
9)_ _ptr64 QUADWORD 
10)Structures, unions, and arrays 
         The largest native member’s alignment requirement, possibly modified by /Zp or #pragma pack. 所以GIFSCREEN按2byte对齐,这样就是10
另外一个当然是1

解决方案 »

  1.   

    多给你说些:
    如果你的结构改成:
    typedef struct fooGIFSCREEN
    {
       WORD   wStr1 ;
       WORD   wStr2 ;
       DWORD   wStr3 ;
       WORD   wStr4 ;
       BYTE   byStr ;
    } GIFSCREEN, * PGIFSCREEN ;
    那就应该是12字节
    如果是:
    typedef struct fooGIFSCREEN
    {
       WORD   wStr1 ; // 0
       WORD   wStr2 ; // 2
       WORD   wStr3 ; // 4
       DWORD   wStr4; // 8,本来偏移是6, 但是DWORD要4字节对其,所以为8
       BYTE   byStr ; // 12, 后面没有了,补3个0达到4字节对其的要求
    } GIFSCREEN, * PGIFSCREEN ;
    就是16字节 (这个结构的alignment requirement由DWORD wStr4决定,为4)
    如果不明白可以给我msg