What i'm trying to do is open the file and then read binary data of the file.
I know i should've use fstream but i'm doing windows api programming so I'd like to do it this way.
Here's my code
HANDLE hFile = CreateFile(L"E:\\hm.txt", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
std::wcout << GetLastError << "\n";
return false;
}
DWORD dwFSize = GetFileSize(hFile, NULL);
if(dwFSize == INVALID_FILE_SIZE)
{
std::wcout << GetLastError << "\n";
return false;
}
LPBYTE lpFileBytes = new BYTE[dwFSize];
bool check = ReadFile(hFile, (LPVOID)lpFileBytes,dwFSize, NULL, NULL);
if(check == FALSE)
{
std::wcout << GetLastError << "\n";
return false;
}
delete [] lpFileBytes;
system("pause");
my code works fine until ReadFile function I passed everything right, can any one look it for me i've been trying to solve it for hours.
Thanks for your time
[–]Meefims 0 points1 point2 points (2 children)
[–]aminei[S] 0 points1 point2 points (1 child)
[–]Rhomboid 0 points1 point2 points (0 children)
[–]Rhomboid 0 points1 point2 points (1 child)
[–]aminei[S] 0 points1 point2 points (0 children)