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

Method GetPackageFullName

TranslucentTB/uwp/uwp.cpp:47–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47std::optional<std::wstring> UWP::GetPackageFullName()
48{
49 static constexpr std::wstring_view FAILED_TO_GET = L"Failed to get package full name";
50
51 UINT32 length = 0;
52 LONG result = GetCurrentPackageFullName(&length, nullptr);
53 if (result != ERROR_INSUFFICIENT_BUFFER) [[unlikely]]
54 {
55 if (result == APPMODEL_ERROR_NO_PACKAGE)
56 {
57 return std::nullopt;
58 }
59 else
60 {
61 HresultHandle(HRESULT_FROM_WIN32(result), spdlog::level::critical, FAILED_TO_GET);
62 }
63 }
64
65 std::wstring familyName;
66 familyName.resize_and_overwrite(length - 1, [](wchar_t* data, std::size_t count)
67 {
68 UINT32 length = static_cast<UINT32>(count) + 1;
69 const LONG result = GetCurrentPackageFullName(&length, data);
70 if (result != ERROR_SUCCESS) [[unlikely]]
71 {
72 HresultHandle(HRESULT_FROM_WIN32(result), spdlog::level::critical, FAILED_TO_GET);
73 }
74
75 return length - 1;
76 });
77
78 return familyName;
79}
80
81std::optional<std::filesystem::path> UWP::GetAppStorageFolder()
82{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected