To load a text file I would expect this code:
wchar_t szFilename[2048];
const wchar_t* pszTextType = L"Text Files\0*.txt\0\0";
bool rtn = GetfilePath(hDlg, szFilename, pszTextType);
The question then arises as to what is in the file and how the content should be processed or displayed.
In the example, this function is called with the file path:
DrawAppImage(hdc, rc.left, rc.top, iWidth, iHeight, szFilename);
What the subroutine looks like exactly has not been said, but from the name it does not sound like text files make sense.