How do you create a new GUID in C ++ in WinRT?

What is equivalent to C # Guid.NewGuid () method in C ++ WinRT?

+4
source share
3 answers
+6
source

If you are writing a Windows Store application (also known as the Metro style), you will need to use CoCreateGuid , since UuidCreate is available only for desktop applications.

From MSDN:

CoCreateGuid:

Applies to: desktop applications | Windows Store Apps
Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.

 HRESULT CoCreateGuid( _Out_ GUID *pguid ); 

UuidCreate:

Applies to: desktop applications only

+4
source

I know jack about Windows 8, but if you still have access to the regular Win32 / 64 APIs, you can use several mechanisms for this. UuidCreate () from rpcrt4 library is one, CoCreateGuid () from oleaut lib is another (which just jumps to the first). The latter has subtleties, at least when deleting your result in a GUID structure directly.

+2
source

Source: https://habr.com/ru/post/1433395/


All Articles