wsl: skip distributions that indicate they are "Modern" (#18183)

This commit is contained in:
Dustin L. Howett 2024-11-13 16:12:47 -06:00 committed by GitHub
parent 772f546ac4
commit 00ff803ace
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -19,6 +19,7 @@ static constexpr std::wstring_view RancherDistributionPrefix{ L"rancher-desktop"
// ⌞ DistributionName: {the name}
static constexpr wchar_t RegKeyLxss[] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Lxss";
static constexpr wchar_t RegKeyDistroName[] = L"DistributionName";
static constexpr wchar_t RegKeyModern[] = L"Modern";
using namespace ::Microsoft::Terminal::Settings::Model;
using namespace winrt::Microsoft::Terminal::Settings::Model;
@ -188,6 +189,12 @@ static bool getWslNames(const wil::unique_hkey& wslRootKey,
continue;
}
const auto modernValue{ wil::reg::try_get_value<uint32_t>(distroKey.get(), RegKeyModern) };
if (modernValue.value_or(0u) == 1u)
{
continue;
}
std::wstring buffer;
auto result = wil::AdaptFixedSizeToAllocatedResult<std::wstring, 256>(buffer, [&](PWSTR value, size_t valueLength, size_t* valueLengthNeededWithNull) -> HRESULT {
auto length = gsl::narrow<DWORD>(valueLength * sizeof(wchar_t));

View File

@ -24,6 +24,7 @@
#endif
#include <wil/cppwinrt.h>
#include <wil/registry.h>
#include <winrt/Windows.ApplicationModel.AppExtensions.h>
#include <winrt/Windows.ApplicationModel.h>