Click to See Complete Forum and Search --> : create a GUID using c++


macgowan
January 23rd, 2004, 04:39 PM
Hi -

I want to create a GUID in c++ and then write the value to a table using ADO and SQL Server. I understand that SQL Server supports GUIDs as a data type ...

I only know how to use uuidgen.exe or guidgen.exe to create GUIDs ... is there a way in c++ ???

Peace!
Chris

hankdane
January 23rd, 2004, 06:26 PM
Use CoCreateGuid();

macgowan
January 24th, 2004, 11:47 AM
Here is the code to round out the discussion ...
Thanks again!
Chris


_TUCHAR *guidStr = 0x00;

GUID *pguid = 0x00;

pguid = new GUID;

CoCreateGuid(pguid);

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

delete pguid;