I'm writing a software to communicate to a recording device that
if connected to the pc via USB emulates a mass storage device.
Some special features are accessed on that device by communicating
on a special sector on that device. To get access on that sector on windows
I need to:
- open a handle to the newly arrived drive
- fetch the physical drive number via deviceIOControl and IOCTLVolumeGetVolumeDiskExtents
- Open the physicaldrive found there and read and write to a special sector.
So far so good - everything is working fine but getting the first initial
volume handle can take quite long.
what I'm doing is basically this:
var hdl : THandle;
start, stop, freq : INT64;
hdl := INVALID_HANDLE_VALUE;
fHandle := CreateFile( PChar('\\.\' + fDriveLetter + ':'),
FILE_SHARE_WRITE or FILE_SHARE_READ,
OutputDebugString( PChar( Format('Open drive took %.3fms', [(stop - start)/freq*1000]) ));
if hdl = INVALID_HANDLE_VALUE then
raise EVolumeError.Create( 'Cannot Open Drive: '+fDriveLetter+#13#10+
This call can take seconds right until the drive arrived.
My guess is that windows first reads the complete FAT which takes long on
this little recording device which actually always creates files that
reserves the complete disk space (4GB).
Anyone has an idea how to speed up that process? I never need to read anything
from the file system but rather I need the handle the get information
about the underlying physicaldrive number and from there I do my read and write operations.