MCPcopy Create free account
hub / github.com/TranslucentTB/TranslucentTB / GetPackageFamilyName

Method GetPackageFamilyName

TranslucentTB/uwp/uwp.cpp:13–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include "../ProgramLog/error/winrt.hpp"
12
13std::optional<std::wstring> UWP::GetPackageFamilyName()
14{
15 static constexpr std::wstring_view FAILED_TO_GET = L"Failed to get package family name";
16
17 UINT32 length = 0;
18 LONG result = GetCurrentPackageFamilyName(&length, nullptr);
19 if (result != ERROR_INSUFFICIENT_BUFFER) [[unlikely]]
20 {
21 if (result == APPMODEL_ERROR_NO_PACKAGE)
22 {
23 return std::nullopt;
24 }
25 else
26 {
27 HresultHandle(HRESULT_FROM_WIN32(result), spdlog::level::critical, FAILED_TO_GET);
28 }
29 }
30
31 std::wstring familyName;
32 familyName.resize_and_overwrite(length - 1, [](wchar_t* data, std::size_t count)
33 {
34 UINT32 length = static_cast<UINT32>(count) + 1;
35 const LONG result = GetCurrentPackageFamilyName(&length, data);
36 if (result != ERROR_SUCCESS) [[unlikely]]
37 {
38 HresultHandle(HRESULT_FROM_WIN32(result), spdlog::level::critical, FAILED_TO_GET);
39 }
40
41 return length - 1;
42 });
43
44 return familyName;
45}
46
47std::optional<std::wstring> UWP::GetPackageFullName()
48{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected