ReadFile, GlobalLock, etc questions
Trying to read a file that has the basic structure of:
<string> <string> <string> <int> x 9
I am able to succesfully open the file using CreateFile. The probelm is trying to read the file. Since I can't find a fscanf() way of reading the blocks one by one I looked at the boards and it was suggested to read the entire file and then search the string to get the information I want.
Here is my code (for this function) so far:
Code:
void getplayerinfo (void)
{
HANDLE hFile, hBuffer;
DWORD numbytes;
DWORD tmp;
LPSTR szGlobBuffer;
if ( (hFile = CreateFile ("Gnos.dat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
{
MessageBoxPrintf(TEXT("Error Opening File"), TEXT("Error number %d"), GetLastError() );
PostQuitMessage(0);
}
tmp = GetFileSize(hFile, NULL);
hBuffer = GlobalAlloc ( GHND, tmp + 1);
szGlobBuffer = GlobalLock ( (HGLOBAL) hBuffer);
ReadFile ( hFile, szGlobBuffer, tmp, &numbytes, NULL);
MessageBoxPrintf(TEXT("NAME"), TEXT("%d - %d"), (int) numbytes, (int) tmp);
GlobalUnlock (hBuffer) ;
GlobalFree (hBuffer) ;
CloseHandle (hFile);
}
File data:
Code:
Gnos Twistor Game_Master 100 0 0 0 100 100 100 0 0 900000 0 1
GlobalLock returns the error:
Quote:
ANSI C++ forbids implicit conversion from `void *' in assignment
Compiler: Dev- C++
Version: 4.9.8.1
Platform: WinXP
Any help would be great.