Ok to make this work I had to change the GlobalLock line to:
Code:
lpBuffer = (char *) GlobalLock (hGlobal);
Why? Oh since the code has been redone here is what I have now:
Code:
void getplayerinfo (void)
{
int *p;
GLOBALHANDLE hGlobal;
HANDLE hFile;
DWORD length;
DWORD bytesRead;
LPSTR lpBuffer;
if ( (hFile = CreateFile("gnos.dat", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
{
MessageBoxPrintf(TEXT("ERROR"), TEXT("hFile error %d"), GetLastError() );
PostQuitMessage(0);
}
length = GetFileSize (hFile, NULL);
hGlobal = GlobalAlloc ( GHND, length + 1);
lpBuffer = (char *) GlobalLock (hGlobal);
ReadFile (hFile, lpBuffer, length, &bytesRead, NULL);
MessageBoxPrintf(TEXT("ReadFile"), TEXT("Read: %d out of %d"), (int) bytesRead, length);
MessageBoxPrintf(TEXT("String"), TEXT("%s"), lpBuffer);
}