How to use File operations when used createfile() to open a binary file

Hi,
I have a problem to port the fopen and fclose and subsequent file operation calls to windows calls.
I mean when we use a fopen call on a file I get a file pointer which I can use with fscanf, fprintf, ftell, fseek calls to do my file operations.
But now I need to use createfile() call to open the file which will give me a HANDLE to the file, this HANDLE cannot be used with the file operation calls.
1. Can some body let me know the equivalent of fscanf, fprintf, ftell, fseek etc., other file operation calls that I can use with the HANDLE returned by the createfile().
2. Can we change the HANDLE to a File pointer so that we can use fseek, fprintf.

Thanks in Advance,
Kumar
Last edited on
CreateFile() can be used with:
WriteFile()
ReadFile()
SetFilePointer()

There is no equivalent for fscanf, fprintf as far as I know and a win32 HANDLE cannot be mixed with CRT I/O APIs.

To emulate fscanf and fprintf think what these functions do and implement them yourself. However, I don't see any reason for doing that when you can use CRT directly.
kpk6880 wrote:
I have a problem to port the fopen and fclose and subsequent file operation calls to windows calls.


I don't understand this. They ARE already ported. If you can compile them in Windows then they have already been ported. Every C compiler for Windows already did this.
Topic archived. No new replies allowed.