From c5bff80d5778e0d47f78ee9cf99c5028b9ad6482 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Tue, 13 Oct 2026 18:36:22 +0900 Subject: [PATCH] Windows: restore drive notifications after failed dismounts Restore notifications after silent open file failures and honor suppression. Use SHCNF_FLUSHNOWAIT to start delivery without waiting for completion. --- src/Common/Dlgcode.c | 15 ++++++++------- src/Mount/Mount.c | 7 ++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 654d54c2..3f3dec56 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -9806,15 +9806,16 @@ retry: forced = TRUE; goto retry; } - - // Undo SHCNE_DRIVEREMOVED - wchar_t root[] = { (wchar_t) (nDosDriveNo + L'A'), L':', L'\\', 0 }; - SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL); - - return FALSE; } + else + Error ("UNMOUNT_FAILED", hwndDlg); - Error ("UNMOUNT_FAILED", hwndDlg); + if (result == ERR_FILES_OPEN && !DeviceChangeBroadcastDisabled) + { + // Undo SHCNE_DRIVEREMOVED and start delivery without waiting for completion. + wchar_t root[] = { (wchar_t) (nDosDriveNo + L'A'), L':', L'\\', 0 }; + SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH | SHCNF_FLUSHNOWAIT, root, NULL); + } return FALSE; } diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 565ef859..609dbbf3 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -6380,8 +6380,9 @@ retry: goto retry; } - // Undo SHCNE_DRIVEREMOVED - if ( DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, NULL, 0, &mountList, sizeof (mountList), &dwResult, NULL) + // Undo SHCNE_DRIVEREMOVED and start delivery without waiting for completion. + if ( !DeviceChangeBroadcastDisabled + && DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, NULL, 0, &mountList, sizeof (mountList), &dwResult, NULL) && mountList.ulMountedDrives && (mountList.ulMountedDrives < (1 << 26)) ) @@ -6391,7 +6392,7 @@ retry: if (mountList.ulMountedDrives & (1 << i)) { wchar_t root[] = { (wchar_t) (i + L'A'), L':', L'\\', 0 }; - SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL); + SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH | SHCNF_FLUSHNOWAIT, root, NULL); } } }