Andrew Garrison
Andrew Garrison

Reputation: 7027

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

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

Upvotes: 4

Views: 4021

Answers (3)

yms
yms

Reputation: 10418

If you are writing a Windows Store application (also known as Metro Style) you will have to use CoCreateGuid, since UuidCreate is only available for Desktop applications.

From MSDN:

CoCreateGuid:

Applies to: desktop apps | 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 apps only

Upvotes: 4

WhozCraig
WhozCraig

Reputation: 66254

I know jack about Windows 8, but if you still have access to the regular Win32/64 APIs you can use a number of mechanics for this. UuidCreate() from the rpcrt4 library is one, CoCreateGuid() from the oleaut lib is another (which just forwards to the former). The latter has the nicety of at last dropping your result in a GUID struct directly.

Upvotes: 2

Najzero
Najzero

Reputation: 3212

I believe you look for http://msdn.microsoft.com/en-us/library/windows/desktop/ms688568%28v=vs.85%29.aspx

CoCreateGuid();

Upvotes: 6

Related Questions