ReadFile() Putting Trash in Buffer
Hey,
I had made a simple window using the Forgers tutorials. Now I'm making a program that needs a window, but its in c++ rather then c (as the tutorials are). I was able to fix all of the problems except one when I converted the code, and it is in the readfile() function.
Anyway, after messing with it for a while and reading th documentation in it, I got it to compile:
Code:
void LoadTextFileToEdit(HWND hEdit, HWND window, LPCTSTR pszFileName)
{
LPCTSTR lpBuffer;
LPDWORD dwNumRead;
DWORD size;
size = sizeof(DWORD)*256;
dwNumRead = &size;
ReadFile(&pszFileName, &lpBuffer, size, dwNumRead,NULL);
SetWindowText(window, pszFileName);
SetWindowText(hEdit, lpBuffer);
}
This code will run but the contents of the file is not being read into lpBuffer, or at least not properly, because when I open a file it spits out stuff like:
‹ÿU‹ìSV‹uW¿
I know that the problem is me messing around with code I don't really understand, but if it's not too much trouble could you point out the problem.
Thanks,
David