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.
This commit is contained in:
Mounir IDRASSI
2026-10-13 19:40:11 +09:00
parent c44fce5000
commit c5bff80d57
2 changed files with 12 additions and 10 deletions
+8 -7
View File
@@ -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;
}
+4 -3
View File
@@ -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);
}
}
}