Hello:
Turning around connect and disconnect disk devices I look at
IOCTL_VOLUME_ONLINE and IOCTL_VOLUME_OFFLINE functions.
However I donâ??t find any examples jet.
I test this (in c#):
SafeFileHandle h = CreateFile(â??\\\\.\\Physicaldriver3â??,
GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
IntPtr.Zero, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL |
FILE_FLAG_WRITE_THROUGH,
new SafeFileHandle(IntPtr.Zero, true));
if (!h.IsInvalid)
{
long bret = 0;
bool ret=DeviceIoControl(h,
IOCTL_VOLUME_OFFLINE,IntPtr.Zero,0,IntPtr.Zero,0,
out bret, IntPtr.Zero);
â?¦
Where IOCTL_VOLUME_OFFLINE is 3, meanwhile IOCTL_VOLUME_ONLINE is 2.
The GetLastWin32Error returns 50, I thing â??ERROR_NOT_SUPPORTEDâ??.
The Physicaldriver3 is an USB Memory stick dervice.
I know others ways for disconnect USB, but my target is to reconnect the USB
without human intervention.
Thanks for your time!
--
Juan Segura
www.sd-a.com
juan@sd-a.com