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

前端 未结 7 1477
栀梦
栀梦 2021-01-31 14:04

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++ vers

7条回答
  •  借酒劲吻你
    2021-01-31 15:02

    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.

提交回复
热议问题