But I didnt found a way to get this to work *without* unplug/insert
the USB flash drive on Windows XP. I tried every combination of
FSCTL_LOCK_VOLUME / FSCTL_UNLOCK_VOLUME, FSCTL_MOUNT_VOLUME /
FSCTL_DISMOUNT_VOLUME, On Windows Vista I was able to reinitialize the
drive with this funktions.
I also tried out removing and setting mountpoints again via
GetVolumeNameForVolumeMountPoint, DeleteVolumeMountPoint and
SetVolumeMountPoint. While these funktions worked fine (the
driveletter in windows explorer disapperead and then showed up again)
there was no reinitialization of the drive data itself. windows
explorer still displays the drive as "o Bytes / need to format".
After this I tried out BroadcastSystemMessage with WM_DEVICECHANGE and
DBT_DEVICEARRIVAL / DBT_DEVICEREMOVECOMPLETE with no success.
Finally I tried DeviceIoControl with IOCTL_STORAGE_EJECT_MEDIA /
IOCTL_STORAGE_LOAD_MEDIA. Ironically Im able to remove the drive via
IOCTL_STORAGE_EJECT_MEDIA, but I cant load it again via
IOCTL_STORAGE_LOAD_MEDIA. After the first command the drive is removed
from system, but after the second command it's still removed...
Is there a way to force windows xp to treat a connected flash drive
like it has just been connected to the system?
Thanks a lot for help
There is a possibility to force windows xp to reinitialize the media
just the way I need it. Open "Control Panel", click "Performance and
Maintenance", "Administrative Tools", "Computer Management",
"Storage", "Removable Storage", "Libraries", then rightlick the flash
drive and select "inject". This will perform a reinitialization of the
drive and after that the drive is present in windows explorer with the
new file system and without errors. But I still dont't know what
activities are triggered on "inject". Someone can tell me? Which
funstion(s) from which DLL(s) or which api functions have to be called
to do the same as "inject" does?
Thank you very much
Hi,
What happens when you use the following APIs to refresh
the Windows shell ?
SHChangeNotify(SHCNE_DRIVEADD, SHCNF_PATH, L"G:\", NULL);
SHChangeNotify(SHCNE_DRIVEREMOVED, SHCNF_PATH, L"G:\", NULL);
SHChangeNotify(0, SHCNF_FLUSH, NULL, NULL);
http://msdn2.microsoft.com/en-us/library/ms647673.aspx
Kellie.
> What happens when you use the following APIs to refresh
> the Windows shell ?
>
> SHChangeNotify(SHCNE_DRIVEADD, SHCNF_PATH, L"G:\", NULL);
>
> SHChangeNotify(SHCNE_DRIVEREMOVED, SHCNF_PATH, L"G:\", NULL);
>
> SHChangeNotify(0, SHCNF_FLUSH, NULL, NULL);
Using this functions looks pretty much like calling
FSCTL_DISMOUNT_VOLUME to me. After using SHCNE_DRIVEREMOVED the symbol
and driveletter disappear from windows explorer and then, after using
SHCNE_DRIVEADD, are showing up again. But Windows does not update its
internal data. If the drive was not accessable before the calls it
still isn't after the calls. Looks like SHCNF_FLUSH does not change
this behaviour.
Thank you for the hint though :)
Uwe
When you deactivate the disk device and the reactivate
it, then the drive partitioning should be checked again
by Windows.
Greetings from Germany
Uwe