WriteFile( ) function. Error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello All,
I am writing a format application where i found a strange problem.

I have to write some data in last 512 bytes of partition.
Now the problem is i am able to write data at anyplace except this
location.
when i call the function

bRet = WriteFile(hFile,lpBuffer,length,(LPDWORD)&byteswritten,NULL);

i am getting byteswritten=0 and bRet=TRUE.
It is strange, though no data is written on disk, still it returns
TRUE.

Now if i am running the same application second time, it is executing
successfully.

So i guess it is because of the driver. Because first time when i
format there is NTFS driver which is already running. And during the
first time half of data is written in disk and partition table is
corrupted so driver is unmounted. and second time it is running
successfully.

Then i am calling FSCTL_DISMOUNT_VOLUME for unloading the driver,
still i am facing the same problem,

Can anybody help me please?

thanks,

Hitesh

.



Relevant Pages