On Fri, 24 May 2013 11:47:37 +0200, "Bertram" <nos...@nospam.or>
wrote:
If it compiles it probably malfunctions because CreateFile with
GENERIC_READ and OPEN_EXISTING will NEVER create a file.
You must use GENERIC_WRITE or GENERIC_READ | GENERIC_WRITE along with
CREATE_ALWAYS or it will fail.
You also don't check to see if CreateFile succeeded, hf != NULL.
Ex:
// this will always overwrite the output file.
hf= CreateFile(ofn.lpstrFile, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (!hf)
{
swprintf_s(s, L"Unable to open file %s", ofn.lpstrFile);
MessageBox(hWnd, s, NULL, NULL);
return true;
}
...