-
file i/o
hello good people
can someone plz give an example (if poss wit a brief explanation)
on how to work with the funtions CreateFile, WriteFile, ReadFile.
i'm a bit mixed up with the arguments.
thanks in advance for your kind time
1976
"The truth is an amusing concept"
-
Here's what I got for CreateFile and ReadFile
Unsigned Char Buffer[50]={0};
HANDLE hFile;
DWORD ReadBytes = 16;
DWORD dwRead;
hFile= CreateFile("C:\\Temp\\Temp.txt", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
ReadFile(hFile, &buffer,ReadBytes ,&dwRead ,NULL);
-
Use sizeof() for the readbytes and dwRead as a check that all the data was read.
Also catch the return of ReadFile(), has to be greater than 0 or error.