// Get the length of the file. char bufQuery[32] ; DWORD dwLengthBufQuery = sizeof(bufQuery); BOOL bQuery = ::HttpQueryInfo(hHttpFile, HTTP_QUERY_CONTENT_LENGTH, bufQuery, &dwLengthBufQuery) ;
// Convert length from ASCII string to a DWORD. DWORD dwFileSize = (DWORD)atol(bufQuery) ;
// Allocate a buffer for the file. char* buffer = new char[dwFileSize+1] ;
// Read the file into the buffer. DWORD dwBytesRead ; BOOL bRead = ::InternetReadFile(hHttpFile, buffer, dwFileSize+1, &dwBytesRead); // Put a zero on the end of the buffer. buffer[dwBytesRead] = 0 ;
// Close all of the Internet handles. ::InternetCloseHandle(hHttpFile); ::InternetCloseHandle(hConnect) ; ::InternetCloseHandle(hSession) ;
// Display the file in an edit control. pEditCtrl->SetWindowText(buffer) ;