mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-31 06:25:20 +00:00
OS Detection and setting the old or new settings UI page accordingly (#2674)
* Added code to detect os build number * To set the settings.exe according to the powerToys version that is running * Modified the description of old UI for launcher and keyboard remapper * Using API contracts instead of registry * Removing file that was included by mistake
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
IDS_SETTINGS_DESCRIPTION L"Customize your experience by remapping keys or creating new shortcuts!"
|
||||
IDS_SETTINGS_DESCRIPTION L"This feature requires Windows 10, May 2019 Update"
|
||||
IDS_KEYBOARDMANAGER L"Keyboard Manager"
|
||||
END
|
||||
|
||||
|
Binary file not shown.
@@ -27,4 +27,5 @@
|
||||
#include <winrt/Windows.ApplicationModel.h>
|
||||
#include <winrt/Windows.Storage.h>
|
||||
|
||||
#include <winrt/Windows.Foundation.Metadata.h>
|
||||
#include <wil/resource.h>
|
@@ -207,6 +207,41 @@ BOOL run_settings_non_elevated(LPCWSTR executable_path, LPWSTR executable_args,
|
||||
return process_created;
|
||||
}
|
||||
|
||||
// The following three helper functions determine if the user has a build version higher than or equal to 19h1, as that is a requirement for xaml islands
|
||||
// Source : Microsoft-ui-xaml github
|
||||
// Link: https://github.com/microsoft/microsoft-ui-xaml/blob/c045cde57c5c754683d674634a0baccda34d58c4/dev/dll/SharedHelpers.cpp
|
||||
template<uint16_t APIVersion> bool IsAPIContractVxAvailable()
|
||||
{
|
||||
static bool isAPIContractVxAvailableInitialized = false;
|
||||
static bool isAPIContractVxAvailable = false;
|
||||
if (!isAPIContractVxAvailableInitialized)
|
||||
{
|
||||
isAPIContractVxAvailableInitialized = true;
|
||||
isAPIContractVxAvailable = winrt::Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent(L"Windows.Foundation.UniversalApiContract", APIVersion);
|
||||
}
|
||||
|
||||
return isAPIContractVxAvailable;
|
||||
}
|
||||
|
||||
|
||||
bool IsAPIContractV8Available()
|
||||
{
|
||||
return IsAPIContractVxAvailable<8>();
|
||||
}
|
||||
|
||||
bool Is19H1OrHigher()
|
||||
{
|
||||
return IsAPIContractV8Available();
|
||||
}
|
||||
|
||||
// This function returns true if the build is 19h1 or higher, so that we deploy the new settings.
|
||||
// It returns false otherwise.
|
||||
bool use_new_settings()
|
||||
{
|
||||
return Is19H1OrHigher();
|
||||
}
|
||||
|
||||
|
||||
DWORD g_settings_process_id = 0;
|
||||
|
||||
void run_settings_window()
|
||||
@@ -223,7 +258,15 @@ void run_settings_window()
|
||||
|
||||
// Arg 1: executable path.
|
||||
std::wstring executable_path = get_module_folderpath();
|
||||
executable_path.append(L"\\SettingsUIRunner\\Microsoft.PowerToys.Settings.UI.Runner.exe");
|
||||
|
||||
if (use_new_settings())
|
||||
{
|
||||
executable_path.append(L"\\SettingsUIRunner\\Microsoft.PowerToys.Settings.UI.Runner.exe");
|
||||
}
|
||||
else
|
||||
{
|
||||
executable_path.append(L"\\PowerToysSettings.exe");
|
||||
}
|
||||
|
||||
// Arg 2: pipe server. Generate unique names for the pipes, if getting a UUID is possible.
|
||||
std::wstring powertoys_pipe_name(L"\\\\.\\pipe\\powertoys_runner_");
|
||||
|
Reference in New Issue
Block a user