Unrivaled1
IS-IT--Management
Is there any way to output the contents of a standard ms-dos text file directly into a MessageBox?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
HWND hWnd; //Parent Window handle
LPCTSTR pFileName; //File path
HANDLE hFile = CreateFile(pFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if(hFile != INVALID_HANDLE_VALUE)
{
UINT nFileLen = GetFileSize(hFile, NULL);
if(nFileLen != INVALID_FILE_SIZE)
{
BYTE* pData = new BYTE[nFileLen + 1];
pData[nFileLen] = '\0';
DWORD ncbRead;
if(ReadFile(hFile, (LPVOID)pData, nFileLen, &ncbRead, NULL) && ncbRead == nFileLen)
{
MessageBox(hWnd, pData, "Program Name", MB_OK | MB_ICONINFORMATION);
}
delete[] pData;
}
CloseHandle(hFile);
}