EDN Admin
Well-known member
<span style="font-family:Verdana,Arial,sans-serif
<span style="font-size:12px; line-height:15px Hi,
I am using the following<span style="font-size:12px; line-height:15px code, and it works for binary image download, but the problem is:
<span style="font-size:12px; line-height:15px <br/>
For an image file with 18k size on server side, only 4k can be download and just half of the image can be seen on the client side. <br/>
<br/>
Any ideas?<br/>
<br/>
Thanks.
void Abc::downloadImage()
{
<span style="font-size:12px; line-height:15px DWORD dwSize = 0;
<span style="font-size:12px; line-height:15px <span style="white-spacere DWORD dwDownloaded = 0;
<span style="font-size:12px; line-height:15px <span style="white-spacere LPSTR pszOutBuffer;
<span style="font-size:12px; line-height:15px <span style="white-spacere BOOL bResults = FALSE;
<span style="font-size:12px; line-height:15px <span style="white-spacere HINTERNET hSession = NULL,
<span style="font-size:12px; line-height:15px <span style="white-spacere hConnect = NULL,
<span style="font-size:12px; line-height:15px <span style="white-spacere hRequest = NULL;
<span style="font-size:12px; line-height:15px
<span style="font-size:12px; line-height:15px <span style="white-spacere hSession = WinHttpOpen( L"WinHTTP",
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_NO_PROXY_NAME,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_NO_PROXY_BYPASS, 0);
<span style="font-size:12px; line-height:15px
<span style="font-size:12px; line-height:15px <span style="white-spacere if (hSession)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere hConnect = WinHttpConnect(hSession, L"localhost", INTERNET_DEFAULT_HTTP_PORT, 0);<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="white-spacere; font-size:12px; line-height:15px
<span style="font-size:12px; line-height:15px <span style="white-spacere if (hConnect)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere hRequest = WinHttpOpenRequest( hConnect, L"GET",
<span style="font-size:12px; line-height:15px <span style="white-spacere L"/Abc/images/a.jpg",
<span style="font-size:12px; line-height:15px <span style="white-spacere NULL, WINHTTP_NO_REFERER,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_DEFAULT_ACCEPT_TYPES,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_FLAG_REFRESH);<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <br/>
<span style="font-size:12px; line-height:15px <span style="white-spacere if (hRequest)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere bResults = WinHttpSendRequest( hRequest,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_NO_ADDITIONAL_HEADERS, 0,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <br/>
<span style="font-size:12px; line-height:15px <span style="white-spacere if (bResults)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere bResults = WinHttpReceiveResponse( hRequest, NULL);<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <br/>
<span style="font-size:12px; line-height:15px <span style="white-spacere if (bResults)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere dwSize = 0;
<span style="font-size:12px; line-height:15px <span style="white-spacere if (!WinHttpQueryDataAvailable( hRequest, &dwSize))
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere printf("Error %u in WinHttpQueryDataAvailable.n", GetLastError());
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere if (dwSize > 0)
<span style="font-size:12px; line-height:15px <span style="white-spacere {<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere pszOutBuffer = new char[dwSize+1];
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere if (!pszOutBuffer)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere printf("Out of memoryn");
<span style="font-size:12px; line-height:15px <span style="white-spacere dwSize=0;
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <span style="white-spacere else
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere if (dwSize>0)
<span style="font-size:12px; line-height:15px <span style="white-spacere {<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere ZeroMemory(pszOutBuffer, dwSize+1);
<span style="font-size:12px; line-height:15px <span style="white-spacere if (!WinHttpReadData( hRequest, (LPVOID)pszOutBuffer, dwSize, &dwDownloaded))
<span style="font-size:12px; line-height:15px <span style="white-spacere printf("Error %u in WinHttpReadData.n", GetLastError());<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px
<span style="font-size:12px; line-height:15px <span style="white-spacere HANDLE hFile;
<span style="font-size:12px; line-height:15px <span style="white-spacere DWORD dwNumWritten;
<span style="font-size:12px; line-height:15px <span style="white-spacere BOOL bTest;
<span style="font-size:12px; line-height:15px <span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere std:fstream outfile;
<span style="font-size:12px; line-height:15px <span style="white-spacere outfile.open("D:\1.jpg",std:fstream::binary);
<span style="font-size:12px; line-height:15px <span style="white-spacere outfile.write(pszOutBuffer,dwSize);
<span style="font-size:12px; line-height:15px <span style="white-spacere outfile.close();
<span style="font-size:12px; line-height:15px <span style="white-spacere // Close any open handles.
<span style="font-size:12px; line-height:15px <span style="white-spacere if( hRequest )
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere WinHttpCloseHandle( hRequest );
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <br/>
<span style="font-size:12px; line-height:15px <span style="white-spacere if( hConnect)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere WinHttpCloseHandle( hConnect );
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="white-spacere; font-size:12px; line-height:15px
<span style="font-size:12px; line-height:15px <span style="white-spacere if( hSession)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere WinHttpCloseHandle( hSession );
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<div style="font-size:12px; line-height:15px }
View the full article
<span style="font-size:12px; line-height:15px Hi,
I am using the following<span style="font-size:12px; line-height:15px code, and it works for binary image download, but the problem is:
<span style="font-size:12px; line-height:15px <br/>
For an image file with 18k size on server side, only 4k can be download and just half of the image can be seen on the client side. <br/>
<br/>
Any ideas?<br/>
<br/>
Thanks.
void Abc::downloadImage()
{
<span style="font-size:12px; line-height:15px DWORD dwSize = 0;
<span style="font-size:12px; line-height:15px <span style="white-spacere DWORD dwDownloaded = 0;
<span style="font-size:12px; line-height:15px <span style="white-spacere LPSTR pszOutBuffer;
<span style="font-size:12px; line-height:15px <span style="white-spacere BOOL bResults = FALSE;
<span style="font-size:12px; line-height:15px <span style="white-spacere HINTERNET hSession = NULL,
<span style="font-size:12px; line-height:15px <span style="white-spacere hConnect = NULL,
<span style="font-size:12px; line-height:15px <span style="white-spacere hRequest = NULL;
<span style="font-size:12px; line-height:15px
<span style="font-size:12px; line-height:15px <span style="white-spacere hSession = WinHttpOpen( L"WinHTTP",
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_NO_PROXY_NAME,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_NO_PROXY_BYPASS, 0);
<span style="font-size:12px; line-height:15px
<span style="font-size:12px; line-height:15px <span style="white-spacere if (hSession)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere hConnect = WinHttpConnect(hSession, L"localhost", INTERNET_DEFAULT_HTTP_PORT, 0);<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="white-spacere; font-size:12px; line-height:15px
<span style="font-size:12px; line-height:15px <span style="white-spacere if (hConnect)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere hRequest = WinHttpOpenRequest( hConnect, L"GET",
<span style="font-size:12px; line-height:15px <span style="white-spacere L"/Abc/images/a.jpg",
<span style="font-size:12px; line-height:15px <span style="white-spacere NULL, WINHTTP_NO_REFERER,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_DEFAULT_ACCEPT_TYPES,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_FLAG_REFRESH);<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <br/>
<span style="font-size:12px; line-height:15px <span style="white-spacere if (hRequest)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere bResults = WinHttpSendRequest( hRequest,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_NO_ADDITIONAL_HEADERS, 0,
<span style="font-size:12px; line-height:15px <span style="white-spacere WINHTTP_NO_REQUEST_DATA, 0, 0, 0);
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <br/>
<span style="font-size:12px; line-height:15px <span style="white-spacere if (bResults)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere bResults = WinHttpReceiveResponse( hRequest, NULL);<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <br/>
<span style="font-size:12px; line-height:15px <span style="white-spacere if (bResults)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere dwSize = 0;
<span style="font-size:12px; line-height:15px <span style="white-spacere if (!WinHttpQueryDataAvailable( hRequest, &dwSize))
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere printf("Error %u in WinHttpQueryDataAvailable.n", GetLastError());
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere if (dwSize > 0)
<span style="font-size:12px; line-height:15px <span style="white-spacere {<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere pszOutBuffer = new char[dwSize+1];
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere if (!pszOutBuffer)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere printf("Out of memoryn");
<span style="font-size:12px; line-height:15px <span style="white-spacere dwSize=0;
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <span style="white-spacere else
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere if (dwSize>0)
<span style="font-size:12px; line-height:15px <span style="white-spacere {<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere ZeroMemory(pszOutBuffer, dwSize+1);
<span style="font-size:12px; line-height:15px <span style="white-spacere if (!WinHttpReadData( hRequest, (LPVOID)pszOutBuffer, dwSize, &dwDownloaded))
<span style="font-size:12px; line-height:15px <span style="white-spacere printf("Error %u in WinHttpReadData.n", GetLastError());<span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px
<span style="font-size:12px; line-height:15px <span style="white-spacere HANDLE hFile;
<span style="font-size:12px; line-height:15px <span style="white-spacere DWORD dwNumWritten;
<span style="font-size:12px; line-height:15px <span style="white-spacere BOOL bTest;
<span style="font-size:12px; line-height:15px <span style="white-spacere
<span style="font-size:12px; line-height:15px <span style="white-spacere std:fstream outfile;
<span style="font-size:12px; line-height:15px <span style="white-spacere outfile.open("D:\1.jpg",std:fstream::binary);
<span style="font-size:12px; line-height:15px <span style="white-spacere outfile.write(pszOutBuffer,dwSize);
<span style="font-size:12px; line-height:15px <span style="white-spacere outfile.close();
<span style="font-size:12px; line-height:15px <span style="white-spacere // Close any open handles.
<span style="font-size:12px; line-height:15px <span style="white-spacere if( hRequest )
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere WinHttpCloseHandle( hRequest );
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="font-size:12px; line-height:15px <br/>
<span style="font-size:12px; line-height:15px <span style="white-spacere if( hConnect)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere WinHttpCloseHandle( hConnect );
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<span style="white-spacere; font-size:12px; line-height:15px
<span style="font-size:12px; line-height:15px <span style="white-spacere if( hSession)
<span style="font-size:12px; line-height:15px <span style="white-spacere {
<span style="font-size:12px; line-height:15px <span style="white-spacere WinHttpCloseHandle( hSession );
<span style="font-size:12px; line-height:15px <span style="white-spacere }
<div style="font-size:12px; line-height:15px }
View the full article