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?
GUID structure (guiddef. A GUID is a 128-bit value consisting of one group of 8 hexadecimal digits, followed by three groups of 4 hexadecimal digits each, followed by one group of 12 hexadecimal digits.
A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated.
we use GUID because it have very low probability of being duplicated as it is 128-bit integer(16 bytes) which allow to use GUID across all databse and computer without data collision.
Basically, a a GUID is generated using a combination of: The MAC address of the machine used to generate the GUID (so GUIDs generated on different machines are unique unless MAC addresses are re-used) Timestamp (so GUIDs generated at different times on the same machine are unique)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With