What's the C++ version of Guid.NewGuid()?

Simon picture Simon · Aug 25, 2009 · Viewed 60.6k times · Source

I need to create a GUID in an unmanaged windows C++ project. I'm used to C#, where I'd use Guid.NewGuid(). What's the (unmanaged windows) C++ version?

Answer

Alan picture Alan · Aug 25, 2009

I think CoCreateGuid is what you're after. Example:

GUID gidReference;
HRESULT hCreateGuid = CoCreateGuid( &gidReference );