From d812cf8a5ca46a27756aaae5a10240ca63dec0d9 Mon Sep 17 00:00:00 2001 From: Mara Johnson Date: Sun, 11 Oct 2026 12:55:33 -0400 Subject: [PATCH] Windows MSI: notify Explorer of the PDF association so PdfCraft shows under Open with (#1080) The MSI already registers PdfCraft.Document in .pdf\OpenWithProgids, Capabilities and RegisteredApplications, but Windows Installer never sends SHCNE_ASSOCCHANGED, so Explorer's cached Open with list can miss PdfCraft until sign-out. Send it after install and uninstall from an immediate, ignore-result custom action; test-msi.ps1 checks the action and its order. --- packaging/windows/pdfcraft.wxs | 13 +++++++++++++ packaging/windows/test-msi.ps1 | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/packaging/windows/pdfcraft.wxs b/packaging/windows/pdfcraft.wxs index e8bb53734d..015631bdd8 100644 --- a/packaging/windows/pdfcraft.wxs +++ b/packaging/windows/pdfcraft.wxs @@ -53,11 +53,24 @@ + + + + + + + diff --git a/packaging/windows/test-msi.ps1 b/packaging/windows/test-msi.ps1 index 0b6fa7781e..841c3c4dea 100644 --- a/packaging/windows/test-msi.ps1 +++ b/packaging/windows/test-msi.ps1 @@ -148,6 +148,15 @@ if ($pdfCheckbox[2] -notmatch 'Edit with PdfCraft') { throw "Welcome PDF context $pdfChecked = Read-Row 'SELECT `Value` FROM `CheckBox` WHERE `Property` = ''INSTALLPDFCONTEXTMENU''' 1 Assert-Equal $pdfChecked[0] '1' 'Welcome PDF context-menu value' Assert-NoRow 'SELECT `Registry` FROM `Registry` WHERE `Key` = ''Software\Classes\.pdf'' AND `Name` IS NULL' '.pdf default app' +# #1080: Explorer is told the associations changed (SHCNE_ASSOCCHANGED) after install/uninstall, +# without ever failing setup. 34 = exe in a directory; 64 = ignore its exit code. +$notify = Read-Row 'SELECT `Type`, `Source`, `Target` FROM `CustomAction` WHERE `Action` = ''NotifyAssociationsChanged''' 3 +Assert-Equal $notify[0] '98' 'Association notify action type' +Assert-Equal $notify[1] 'SystemFolder' 'Association notify directory' +if ($notify[2] -notmatch 'SHChangeNotify\(0x8000000,0,0,0\)' -or $notify[2].Length -gt 255) { throw "Association notify command: '$($notify[2])'" } +$after = Read-Row 'SELECT `Sequence` FROM `InstallExecuteSequence` WHERE `Action` = ''NotifyAssociationsChanged''' 1 +$finalize = Read-Row 'SELECT `Sequence` FROM `InstallExecuteSequence` WHERE `Action` = ''InstallFinalize''' 1 +if ([int] $after[0] -le [int] $finalize[0]) { throw 'Association notify must run after InstallFinalize' } # Negative sequences are Windows Installer's success/user-exit/failure paths. Only full UI # shows these dialogs: an unattended /qn or /qb install must never wait for a Finish click.