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

前端 未结 7 1474
栀梦
栀梦 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 14:49

    In the new WinRT api you can use winrt::Windows::Foundation::GuidHelper::CreateNewGuid() which returns a struct of winrt::guid type. You can later pass it to winrt::to_hstring to get struct of winrt::hstring type, then pass it to winrt::to_string to get std::string type.

提交回复
热议问题