In rpc.h, the GUID structure is declared as follows:
typedef struct _GUID { DWORD Data1; WORD Data2; WORD Data3; BYTE Data[8]; } GUID;
I understand Data1, Data2, and Data3. They define the first, second, and third sets of hex digits when writing out a GUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX).
What I never understood was why the last 2 groups were declared together in the same byte array. Wouldn’t this have made more sense (and been easier to code against)?
typedef struct _GUID { DWORD Data1; WORD Data2; WORD Data3; WORD Data4; BYTE Data5[6]; } GUID;
Anyone know why it is declared this way?
It’s because a GUID is a special case of a UUID. For information on what all the fields mean, you can look at RFC 4122.