|Happy New Month to you all.
However, l am playing with Createfile, WriteFile and ReadFile functions, Createfile and Writefile works well but my problem is ReadFile.
l want to read the data written to a buffer "szBuffer", by using "ReadFile" to read the data in the szBuffer into another buffer szBuf. But it doesn't work.
When l check the return value like error=ReadFile(hfile,szBuffer,10,&in,NULL), it returns 0 but when l use GetLastError() to check for the return value, it gives me 998. l learnt that the second parameter to ReadFile() is the address to store the data read.
Code snippet below:
lang="c++">hfile=CreateFile("C:\file.txt",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);// this works well
WriteFile(hfile,szBuffer,256,&in,NULL);//this works well
ReadFile(hfile,szBuf,256,&in,NULL);//this does not read data
TextOut(hdc,50,300,szerror,wsprintf(szerror,"%i",GetLastError()));//check return value
Can someone help me to overcome this?
modified 4-Apr-16 9:59am.