I need to be able to create guids on the fly. Is there a way to do that in MFC? I see how to do it in .net, but we haven't gone there yet. If not, do you have pointers to some code I can use?
+3
A:
Use the function UuidCreate to generate GUIDs :
UUID generated;
if (::UuidCreate(&generated) != RPC_S_OK)
throw std::exception(...);
Edouard A.
2009-02-17 14:20:48
+2
A:
You can use the COM function CoCreateGuid, e.g.:
GUID guid;
HRESULT hr = CoCreateGuid(&guid);
John Sibly
2009-02-17 14:22:21
+4
A:
_TUCHAR * guidStr;
GUID guid;
HRESULT hr = CoCreateGuid(&guid);
// Convert the GUID to a string
UuidToString(&guid, &guidStr);
The application is responsible for calling RpcStringFree
to deallocate the memory allocated for the string returned in the StringUuid parameter.
Mitch Wheat
2009-02-17 14:27:27