Hello pgnatyuk,
Thank you for your posting, but, unfortunately, it did not help. :( I understand the API and the code that I have, can create and write to a file. The issue is that SetFilePointer() is returning "invalid file handle" even just after the file has been successfully created. However, the same handle successfully permits writing to the file, which results in files that are not empty when I exit (when removing FILE_FLAG_DELETE_ON_CLOSE from CreateFile()). So, I still believe that something is not quite correct with the CreateFile() when using it for Reading and Writing to a created and opened file. The MSDN docs say that "The file handle must be created with the GENERIC_READ OR GENERIC_WRITE access right." ORRRRRRRRRRRRRRRRRRRRRR So, I wonder whether I cannot use SetFilePointer() on a file that has been opened for (GENERIC_READ | GENERIC_WRITE), which would be really strange. Anyway, I hope that this info helps and we can figure out what is going on... Worst case, I can create the file, write it, close it... open the file, read it, close it... Delete it... But, according to what I've read, my current code should work... Arggg... Very frustrating... Win32 never gives up it secrets easily... :P
Main Topics
Browse All Topics





by: pgnatyukPosted on 2009-10-17 at 23:23:52ID: 25598909
Please check the code I attached. It is your code with few modifications done to illustrate the API. SetFilePointer works with hFile handle. Please compare with your code.
You use FILE_FLAG_DELETE_ON_CLOSE flag, so the file is deleted on close.
Select allOpen in new window