How to create a GUID programmatically?

Do the following…

[sourcecode language=’cpp’]GUID guId = { 0 };
CoCreateGuid( &guId );
// or
UUID uid = { 0 };
UuidCreate( &uid );[/sourcecode]

For converting to string use…

[sourcecode language=’cpp’]PUCHAR pChar = 0;

// Convert to string
UuidToString( &uid, &pChar );
MessageBox( NULL, (char*)pChar, NULL, MB_OK );

//Don’t forget to free allocated string
RpcStringFree( &pChar );[/sourcecode]

Appreciate your comments...