Hi guys,
Any idea on how I might be able to cast a char[32] to a GUID?
Thanks in advance
Casting problems
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]
[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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement