blob: c03538922638cd3f43b4433da9e3f14d73a81458 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// 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.
#include "precomp.h"
extern "C" HRESULT DAPI GuidFixedCreate(
_Out_z_cap_c_(GUID_STRING_LENGTH) WCHAR* wzGuid
)
{
HRESULT hr = S_OK;
UUID guid = { };
hr = HRESULT_FROM_RPC(::UuidCreate(&guid));
ExitOnFailure(hr, "UuidCreate failed.");
if (!::StringFromGUID2(guid, wzGuid, GUID_STRING_LENGTH))
{
hr = E_OUTOFMEMORY;
ExitOnRootFailure(hr, "Failed to convert guid into string.");
}
LExit:
return hr;
}
extern "C" HRESULT DAPI GuidCreate(
__deref_out_z LPWSTR* psczGuid
)
{
HRESULT hr = S_OK;
hr = StrAlloc(psczGuid, GUID_STRING_LENGTH);
ExitOnFailure(hr, "Failed to allocate space for guid");
hr = GuidFixedCreate(*psczGuid);
ExitOnFailure(hr, "Failed to create new guid.");
LExit:
return hr;
}
|