OpenFile() has been superseded by CreateFile()
This will return the HANDLE to a file given the path, including the name of the file. It will display a message box if it fails (with the error code).
Code:
HANDLE OpenDocument(HWND hDlg, char *sFilePath)
{
char sBuffer[STRING];
int iError=INVALID;
HANDLE hFile;
hFile=CreateFile(sFilePath, GENERIC_WRITE|GENERIC_READ ,0 ,NULL ,OPEN_ALWAYS ,FILE_ATTRIBUTE_NORMAL ,NULL);
if((hFile == NULL)||(hFile == INVALID_HANDLE_VALUE))
{
iError=GetLastError();
sprintf(sBuffer,"%s file failed to open with Error #:%d",sFilePath,iError);
MessageBox(hDlg,sBuffer,"MyAppError",MB_ICONERROR|MB_OK);
return NULL;
}
else
{
return hFile;
}
}
Look up the flags I have used as I want the file to be created if it does not exist and may want to write to it.
Use Readfile() and SetFilePointer() to read data from the file.