delphi - Speed up createFile call on volumes -
i'm writing software communicate recording device if connected pc via usb emulates mass storage device. special features accessed on device communicating on special sector on device. access on sector on windows need to:
- open handle newly arrived drive
- fetch physical drive number via deviceiocontrol , ioctlvolumegetvolumediskextents
- open physicaldrive found there , read , write special sector.
so far - working fine getting first initial volume handle can take quite long.
what i'm doing this:
var hdl : thandle; start, stop, freq : int64; begin hdl := invalid_handle_value; queryperformancefrequency(freq); queryperformancecounter(start); fhandle := createfile( pchar('\\.\' + fdriveletter + ':'), generic_read, file_share_write or file_share_read, nil, open_existing, 0, 0); queryperformancecounter(stop); outputdebugstring( pchar( format('open drive took %.3fms', [(stop - start)/freq*1000]) )); if hdl = invalid_handle_value raise evolumeerror.create( 'cannot open drive: '+fdriveletter+#13#10+ syserrormessage(getlasterror)); end; this call can take seconds right until drive arrived.
my guess windows first reads complete fat takes long on little recording device creates files reserves complete disk space (4gb). has idea how speed process? never need read file system rather need handle information underlying physicaldrive number , there read , write operations.
Comments
Post a Comment