// Returns the system description for the specified error code.
//
// Dependencies: CString
//
// Web: http://unclassified.software/source/formaterrormsg
//
CString FormatErrorMsg(DWORD dwErr)
{
	LPVOID lpMsgBuf;
	CString msg;

	FormatMessage(
		FORMAT_MESSAGE_ALLOCATE_BUFFER |
		FORMAT_MESSAGE_FROM_SYSTEM |
		FORMAT_MESSAGE_IGNORE_INSERTS,
		NULL,
		dwErr,
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),   // Default language
		(LPTSTR) &lpMsgBuf,
		0,
		NULL
	);
	msg = (char *) lpMsgBuf;
	LocalFree(lpMsgBuf);
	return msg;
}
