Casting problems

Started by
1 comment, last by DividedByZero 11 years, 9 months ago
Hi guys,

Any idea on how I might be able to cast a char[32] to a GUID?

Thanks in advance :)
Advertisement
A guid has only 16 bytes, so your char[32] are actually real 32 digits in hexadecimal format ? Then transform your hex digits into 16 bytes,which can be casted then to:

[source lang="cpp"]
byte byteArray[16];
//.. convert 32 digits to 16 byte array, 2 digits creating one byte

// .. shift bytes according to endianness to fit following structure
/*
typedef struct _GUID {
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data4[8];
} GUID
*/

GUID* myGuid = (GUID*)byteArray;
[/source]
Awesome, you have sent me in the right direction! :)

This topic is closed to new replies.

Advertisement