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); } } }