How to close a file opened with CreateFile API
-
I have opened and successfully read from a text file using CreateFile and ReadFile api's, but how can I close the file. Thank you
CloseHandle -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com
-
CloseHandle -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com
-
I have opened and successfully read from a text file using CreateFile and ReadFile api's, but how can I close the file. Thank you
I assume you are developing in Win32. Use CloseHandle() to close the file. The following is taken from the Win32 documentation for CreateFile() : "Use the CloseHandle function to close an object handle returned by CreateFile." Note that it is very important to call CloseHandle(). Otherwise, the handle table of your application will continue to grow and you will run out of memory in the long term. After closing the handle, it is best to set the value of your handle variable to NULL so that you do not close the handle again. Closing a handle twice will raise an exception.