I'm doing a file hasher, I'm starting with MD5, I'm following this example but I didn't want to use window's function, I'm using normal md5 functions.
It compiles fine but I get an error while running it. Aditionally I would like to know if is there a function that would take the number given by GetLastError() and convert it into the description of the error.
HANDLE hFile = NULL;
BOOL bResult = FALSE;
DWORD cbRead = 0;
unsigned char* md5;
hFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if (hFile == INVALID_HANDLE_VALUE)
wsprintf(lpOut, "Error opening file! Error: %d\0", GetLastError());
MessageBox(hwnd, lpOut, "Error", MB_OK | MB_ICONERROR);
while (bResult = ReadFile(hFile, rgbFile, BUFSIZE, &cbRead, NULL))
if (cbRead == 0)
MD5Update(&context, rgbFile, BUFSIZE);
SetDlgItemText(hwnd, HSH_MD5, md5);