Creating a GUID
I have been looking at ways to create a GUID. Below is the code I plan on implementing. Since, I am still cutting my teeth on C++. I wanted to get some feed back.
Thanks in advance for your help/input.
CString BuildGUID()
{
long lRetVal = 0;
GUID *oGuid;
CString strPartOne;
CString strPartTwo;
CString strPartThree;
CString strPartFour;
CString strGUID;
// Int variables
strGUID = " ";
oGuid = new GUID;
// Call the API Function to get the GUID
lRetVal = CoCreateGuid(oGuid);
// Build the guid
if (lRetVal == 0)
{
// Get the first 8 characters
strPartOne.Format("%X_", oGuid->Data1);
// Get the next 4 characters
strPartTwo.Format("%X_", oGuid->Data2);
// Get the next 4 characters
strPartThree.Format("%X_", oGuid->Data3);
// Get the next 6 characters
strPartFour.Format("%X", oGuid->Data4);
// Build the GUID
strGUID = strPartOne + strPartTwo + strPartThree + strPartFour;
}
// Return the GUID
return strGUID;
}
Larry Asher
__________________
Larry Asher
|