feat: suppress runtime file associations in MSIX Store build

This commit is contained in:
SoftFever
2026-06-11 04:37:23 +08:00
parent 53c2ec2e32
commit 42b7bcaf0d
2 changed files with 14 additions and 0 deletions

View File

@@ -9114,6 +9114,10 @@ static bool del_win_registry(HKEY hkeyHive, const wchar_t *pszVar, const wchar_t
void GUI_App::associate_files(std::wstring extend)
{
#ifdef WIN32
// MSIX: shell integration is declared in the package manifest; registry
// writes from a packaged process are virtualized and invisible to the shell.
if (is_running_in_msix())
return;
wchar_t app_path[MAX_PATH];
::GetModuleFileNameW(nullptr, app_path, sizeof(app_path));
@@ -9139,6 +9143,8 @@ void GUI_App::associate_files(std::wstring extend)
void GUI_App::disassociate_files(std::wstring extend)
{
#ifdef WIN32
if (is_running_in_msix())
return;
wchar_t app_path[MAX_PATH];
::GetModuleFileNameW(nullptr, app_path, sizeof(app_path));
@@ -9190,6 +9196,8 @@ bool GUI_App::check_url_association(std::wstring url_prefix, std::wstring& reg_b
void GUI_App::associate_url(std::wstring url_prefix)
{
#ifdef WIN32
if (is_running_in_msix())
return;
boost::filesystem::path binary_path(boost::filesystem::canonical(boost::dll::program_location()));
wxString wbinary = from_path(binary_path);
BOOST_LOG_TRIVIAL(info) << "Downloader registration: Path of binary: " << wbinary.ToUTF8().data();
@@ -9215,6 +9223,8 @@ void GUI_App::associate_url(std::wstring url_prefix)
void GUI_App::disassociate_url(std::wstring url_prefix)
{
#ifdef WIN32
if (is_running_in_msix())
return;
wxRegKey key_full(wxRegKey::HKCU, "Software\\Classes\\" + url_prefix + "\\shell\\open\\command");
if (!key_full.Exists()) {
return;

View File

@@ -1846,6 +1846,9 @@ void PreferencesDialog::create_items()
//// ASSOCIATE TAB
/////////////////////////////////////
#ifdef _WIN32
// MSIX: associations are declared in the package manifest and defaults are
// managed by Windows Settings; the runtime registry toggles below cannot work.
if (!is_running_in_msix()) {
m_pref_tabs->AppendItem(_L("Associate"));
f_sizers.push_back(new wxFlexGridSizer(1, 1, v_gap, 0));
g_sizer = f_sizers.back();
@@ -1880,6 +1883,7 @@ void PreferencesDialog::create_items()
g_sizer->AddSpacer(FromDIP(10));
sizer_page->Add(g_sizer, 0, wxEXPAND);
}
#endif // _WIN32
//////////////////////////