Click to See Complete Forum and Search --> : CreateFile delay


samnemo
September 26th, 2005, 01:51 PM
hi

i am using createfile like so :

HANDLE hFILE = CreateFile(file.c_str(),GENERIC_READ |
GENERIC_WRITE,FILE_SHARE_DELETE,0,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,0)));

i am doing this to get a HANDLE to a file and leave the file locked so
that no other processes may read / write it ( with the exception of
deleting ) . CreateFile is quick on a local drive and remote drive on
the LAN when the file is unlocked. When I try CreateFile on a UNC path
to a file on the LAN and that file is already "locked" then I get a
delay of about 1.5 seconds. if I do the same thing for a local file
that is already "locked" the delay is only about 10MS. (timing obtained
using GetTickCount() ).

i tried creating separate threads to call CreateFile asynchronously.
this helps for my purposes but leads to other problems...

Does anyone know if there is a way to speed CreateFile up and why it is
taking so long? Any help would be appreciated.

thanks
sam