mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 18:43:54 -06:00
Fix an exception on startup (#17960)
It bothered me. :) ## Validation Steps Performed * Launch packaged WT. `IsPackaged() == true` ✅ * Launch unpackaged WT. `IsPackaged() == false` ✅
This commit is contained in:
parent
37aba3157c
commit
a8e0b9ccf6
@ -1,22 +1,26 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
constexpr std::wstring_view WtExe{ L"wt.exe" };
|
constexpr std::wstring_view WtExe{ L"wt.exe" };
|
||||||
constexpr std::wstring_view WtdExe{ L"wtd.exe" };
|
constexpr std::wstring_view WtdExe{ L"wtd.exe" };
|
||||||
constexpr std::wstring_view WindowsTerminalExe{ L"WindowsTerminal.exe" };
|
constexpr std::wstring_view WindowsTerminalExe{ L"WindowsTerminal.exe" };
|
||||||
constexpr std::wstring_view LocalAppDataAppsPath{ L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\" };
|
constexpr std::wstring_view LocalAppDataAppsPath{ L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\" };
|
||||||
constexpr std::wstring_view ElevateShimExe{ L"elevate-shim.exe" };
|
constexpr std::wstring_view ElevateShimExe{ L"elevate-shim.exe" };
|
||||||
|
|
||||||
|
// Forward declared from appmodel.h so that we don't need to pull in that header everywhere.
|
||||||
|
extern "C" {
|
||||||
|
WINBASEAPI LONG WINAPI GetCurrentPackageId(UINT32* bufferLength, BYTE* buffer);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef WINRT_Windows_ApplicationModel_H
|
#ifdef WINRT_Windows_ApplicationModel_H
|
||||||
_TIL_INLINEPREFIX bool IsPackaged()
|
_TIL_INLINEPREFIX bool IsPackaged()
|
||||||
{
|
{
|
||||||
static const auto isPackaged = []() -> bool {
|
static const auto isPackaged = []() {
|
||||||
try
|
UINT32 bufferLength = 0;
|
||||||
{
|
const auto hr = GetCurrentPackageId(&bufferLength, nullptr);
|
||||||
const auto package = winrt::Windows::ApplicationModel::Package::Current();
|
return hr != APPMODEL_ERROR_NO_PACKAGE;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}();
|
}();
|
||||||
return isPackaged;
|
return isPackaged;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user