windows.h ReadFile() [beginner] problem

Hi, I am returning to c++ after a couple years, and with only basic knowledge, and am trying to go through different aspects of programming with windows.h (using dev c++).

I am currently trying to do a ReadFile() in which the file is read, and displays the read text in a messagebox as such:
<code>
char textin[]= "";
DWORD x, y;


hFile1 = CreateFile("test.txt",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL
);
GetFileSize(
hFile1,
&x
);
ReadFile(
hFile1,
textin,
x,
&y,
NULL
);


MessageBox(hwnd, textin, "test", MB_ICONINFORMATION);


CloseHandle(hFile1);
</code>
The above code is triggered by a button press, but the messagebox always comes out blank. I am sure it is a rookie mistake but after much head scratching and searching for answers I can't figure out what is going on, so any insight is apprectiated.

Thanks,
mkeras2
GetFileSize function is your problem. The following website will help.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa364955(v=vs.85).aspx
Topic archived. No new replies allowed.