1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
static TCHAR szBuffer[100]="Read file testing"; static TCHAR *szBuf; DWORD in; static TCHAR szerror[100];
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,10,&in,NULL);//this works well
SetFilePointer(hfile,0,0,FILE_BEGIN);
ReadFile(hfile,szBuf,10,&in,NULL);//this does not read data
CloseHandle(hfile);
hdc=GetDC(hwnd);
TextOut(hdc,0,100,szBuf,10)// to see print out, but nothing prints.
TextOut(hdc,50,300,szerror,wsprintf(szerror,"%i",GetLastError()));//check return value
ReleaseDC(hwnd,hdc);
|