diff options
Diffstat (limited to 'src/dutil/guidutil.cpp')
-rw-r--r-- | src/dutil/guidutil.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/dutil/guidutil.cpp b/src/dutil/guidutil.cpp new file mode 100644 index 00000000..c0353892 --- /dev/null +++ b/src/dutil/guidutil.cpp | |||
@@ -0,0 +1,39 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | #include "precomp.h" | ||
4 | |||
5 | extern "C" HRESULT DAPI GuidFixedCreate( | ||
6 | _Out_z_cap_c_(GUID_STRING_LENGTH) WCHAR* wzGuid | ||
7 | ) | ||
8 | { | ||
9 | HRESULT hr = S_OK; | ||
10 | UUID guid = { }; | ||
11 | |||
12 | hr = HRESULT_FROM_RPC(::UuidCreate(&guid)); | ||
13 | ExitOnFailure(hr, "UuidCreate failed."); | ||
14 | |||
15 | if (!::StringFromGUID2(guid, wzGuid, GUID_STRING_LENGTH)) | ||
16 | { | ||
17 | hr = E_OUTOFMEMORY; | ||
18 | ExitOnRootFailure(hr, "Failed to convert guid into string."); | ||
19 | } | ||
20 | |||
21 | LExit: | ||
22 | return hr; | ||
23 | } | ||
24 | |||
25 | extern "C" HRESULT DAPI GuidCreate( | ||
26 | __deref_out_z LPWSTR* psczGuid | ||
27 | ) | ||
28 | { | ||
29 | HRESULT hr = S_OK; | ||
30 | |||
31 | hr = StrAlloc(psczGuid, GUID_STRING_LENGTH); | ||
32 | ExitOnFailure(hr, "Failed to allocate space for guid"); | ||
33 | |||
34 | hr = GuidFixedCreate(*psczGuid); | ||
35 | ExitOnFailure(hr, "Failed to create new guid."); | ||
36 | |||
37 | LExit: | ||
38 | return hr; | ||
39 | } | ||