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?
views:
407answers:
3
+12
A:
UuidCreate() in Win32 API has exactly the same effect. However you need to pass an address of the variable that will receive the generated value:
UUID newId;
UuidCreate( &newId );
I believe Guid.NewGuid() simply maps onto it inside the .NET runtime.
sharptooth
2009-08-25 09:39:49
That makes a UUID structure, not a GUID structure.
Simon
2009-08-25 09:41:31
They're the same, simply different typedef names!
Konrad Rudolph
2009-08-25 09:42:52
+5
A:
I think CoCreateGuid
is what you're after. Example:
GUID gidReference;
HRESULT hCreateGuid = CoCreateGuid( &gidReference );
Alan
2009-08-25 09:41:38
+1
A:
You should probably check out he win32 API here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/html/8d5cedea-8c2b-4918-99db-1a000989f178.asp
and here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rpc/rpc/guid.asp
Robban
2009-08-25 09:42:00