cpp

_TUCHAR *guidStr = 0x00;

GUID *pguid = 0x00;

pguid = new GUID;

CoCreateGuid(pguid);

// Convert the GUID to a string
UuidToString(pguid, &guidStr);

delete pguid; 
source