• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ InternetReadFile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中InternetReadFile函数的典型用法代码示例。如果您正苦于以下问题:C++ InternetReadFile函数的具体用法?C++ InternetReadFile怎么用?C++ InternetReadFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了InternetReadFile函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sprintf

int P3DUpdateManager::CheckForUpdates(const char* bugServer)
{
    if (!CVe_updates.GetBool()) return false;

    char *query = new char[128];
    char *outResult = new char[1024];

    sprintf(query, "%s/?a=d&v1=%d&v2=%d&v3=%d&v4=%d", bugServer, P3DVER_1, P3DVER_2, P3DVER_3, P3DVER_4);
    //do
    //{
    HINTERNET hInet = InternetOpen("P3DUP", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
    HINTERNET hFile = InternetOpenUrl(hInet, query, NULL, 0, INTERNET_FLAG_RELOAD, 0);
    if (!hInet || !hFile) return 0;
    DWORD size;
    outResult[0]=0;
    if (!InternetReadFile(hFile, outResult, 1023, &size))
        return 0;
    outResult[size]=0;
    if (!InternetCloseHandle(hFile)) return 0;
    if (!InternetCloseHandle(hInet)) return 0;
    //}while(outResult[0]==0);

    // zjisti pocet updatu
    unsigned int lastPos=0;
    for (unsigned int i=0; i<strlen(outResult); i++)
    {
        if (outResult[i]==';')
        {
            char* tmpChar = new char[i-lastPos+1];
            strncpy(tmpChar, &outResult[lastPos], i-lastPos);
            tmpChar[i-lastPos]=0;
            m_pUpdLinks.push_back(tmpChar);

            lastPos = i+1;
            m_nUpdates++;
        }
    }

    delete[] query;
    delete[] outResult;

    return m_nUpdates;
    return 0;
}
开发者ID:k3a,项目名称:Panther3D-1,代码行数:44,代码来源:updater.cpp


示例2: DownloadToMemory

LPBYTE DownloadToMemory(IN LPCTSTR lpszURL, OUT PDWORD_PTR lpSize)
{
	LPBYTE lpszReturn = 0;
	*lpSize = 0;
	const HINTERNET hSession = InternetOpen(TEXT("GetGitHubRepositoryList"), INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_NO_COOKIES);
	if (hSession)
	{
		URL_COMPONENTS uc = { 0 };
		TCHAR HostName[MAX_PATH];
		TCHAR UrlPath[MAX_PATH];
		uc.dwStructSize = sizeof(uc);
		uc.lpszHostName = HostName;
		uc.lpszUrlPath = UrlPath;
		uc.dwHostNameLength = MAX_PATH;
		uc.dwUrlPathLength = MAX_PATH;
		InternetCrackUrl(lpszURL, 0, 0, &uc);
		const HINTERNET hConnection = InternetConnect(hSession, HostName, INTERNET_DEFAULT_HTTPS_PORT, 0, 0, INTERNET_SERVICE_HTTP, 0, 0);
		if (hConnection)
		{
			const HINTERNET hRequest = HttpOpenRequest(hConnection, TEXT("GET"), UrlPath, 0, 0, 0, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
			if (hRequest)
			{
				HttpSendRequest(hRequest, 0, 0, 0, 0);
				lpszReturn = (LPBYTE)GlobalAlloc(GMEM_FIXED, 1);
				DWORD dwRead;
				static BYTE szBuf[1024 * 4];
				LPBYTE lpTmp;
				for (;;)
				{
					if (!InternetReadFile(hRequest, szBuf, (DWORD)sizeof(szBuf), &dwRead) || !dwRead) break;
					lpTmp = (LPBYTE)GlobalReAlloc(lpszReturn, (SIZE_T)(*lpSize + dwRead), GMEM_MOVEABLE);
					if (lpTmp == NULL) break;
					lpszReturn = lpTmp;
					CopyMemory(lpszReturn + *lpSize, szBuf, dwRead);
					*lpSize += dwRead;
				}
				InternetCloseHandle(hRequest);
			}
			InternetCloseHandle(hConnection);
		}
		InternetCloseHandle(hSession);
	}
	return lpszReturn;
}
开发者ID:kenjinote,项目名称:GetGitHubRepositoryList,代码行数:44,代码来源:Source.cpp


示例3: _T

bool CHTTPParser::readString(CString& rString, HINTERNET hFile)
{
	const DWORD dwBufferSize = 1024;
	DWORD dwRead = 0;
	CHAR svBuffer[dwBufferSize];

	rString = _T("");

	ZeroMemory(svBuffer, dwBufferSize);
	
	while(InternetReadFile(hFile, svBuffer, dwBufferSize, &dwRead) && dwRead != 0)
	{
		CA2T pszBuffer((LPCSTR)svBuffer);
		
		rString.Append(pszBuffer);
	}

	return true;
}
开发者ID:openxtra,项目名称:hotspot-sdk,代码行数:19,代码来源:HTTPParser.cpp


示例4: http_get

bool http_get(LPCTSTR szURL, LPCTSTR szFileName)
{
    HINTERNET	hInternet, hUrl;
    HANDLE		hFile;
    char		buffer[1024];
    DWORD		dwBytesRead = 0;
    DWORD		dwBytesWritten = 0;
    BOOL		bIsFirstPacket = true;
    BOOL		bRet = true;
    hInternet = InternetOpen("Mozilla/4.0 (compatible)", INTERNET_OPEN_TYPE_PRECONFIG, NULL,INTERNET_INVALID_PORT_NUMBER,0);
    if (hInternet == NULL)
        return false;

    hUrl = InternetOpenUrl(hInternet, szURL, NULL, 0, INTERNET_FLAG_RELOAD, 0);
    if (hUrl == NULL)
        return false;

    hFile = CreateFile(szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);

    if (hFile != INVALID_HANDLE_VALUE)
    {
        do
        {
            memset(buffer, 0, sizeof(buffer));
            InternetReadFile(hUrl, buffer, sizeof(buffer), &dwBytesRead);
            // 由判断第一个数据包是不是有效的PE文件
            if (bIsFirstPacket && ((PIMAGE_DOS_HEADER)buffer)->e_magic != IMAGE_DOS_SIGNATURE)
            {
                bRet = false;
                break;
            }
            bIsFirstPacket = false;

            WriteFile(hFile, buffer, dwBytesRead, &dwBytesWritten, NULL);
        } while(dwBytesRead > 0);
        CloseHandle(hFile);
    }

    InternetCloseHandle(hUrl);
    InternetCloseHandle(hInternet);

    return bRet;
}
开发者ID:xinba123,项目名称:shell,代码行数:43,代码来源:until.cpp


示例5: get_url_string

bool get_url_string(wstring url, string &out)
{
	char buffer[HTTP_BUFFER_LEN];//下载文件的缓冲区
	DWORD bytes_read = 1;//下载的字节数
	bool getre = false;
	out = "";

	if(url.length() < 6)
		return false;

	//打开一个internet连接
	HINTERNET internet=InternetOpen(_T("User-Agent"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL);
	if(!internet)
		return false;

	DWORD timeout = 5000;
	InternetSetOption(internet, INTERNET_OPTION_CONNECT_TIMEOUT, &timeout, sizeof(DWORD));

	timeout = 10000;
	InternetSetOption(internet, INTERNET_OPTION_SEND_TIMEOUT, &timeout, sizeof(DWORD));

	//打开一个http url地址
	HINTERNET file_handle=InternetOpenUrl(internet, url.c_str(), NULL, 0, INTERNET_FLAG_RELOAD, 0);

	if(file_handle) {
		//从url地址中读取文件内容到缓冲区buffer
		BOOL b = 0;
		int readbyte = 0;
		while(bytes_read > 0) {
			b = InternetReadFile(file_handle, buffer, 512 , &bytes_read);
			if(!b)
				break;
			readbyte += bytes_read;
			buffer[bytes_read] = 0;
			out += buffer;
		}
		getre = true;
	}
	//关闭连接
	InternetCloseHandle(internet);

	return getre;
}
开发者ID:william0wang,项目名称:meditor,代码行数:43,代码来源:shared.cpp


示例6: FetchMore

int HttpSnaffle::FetchMore(std::ostream& out)
{
    // Find out how much there is to download
    DWORD dwSize;
    if (!InternetQueryDataAvailable(myRequest, &dwSize, 0, 0))
        return -1;

	if (!dwSize)
		return 0;

    // Make sure buffer is big enough
    myBuffer.resize(dwSize);

    // Read the data
    DWORD dwDownloaded;
    if (!InternetReadFile(myRequest, (LPVOID)&myBuffer[0], dwSize, &dwDownloaded))
        return -1;

    // See if we're done
    if (dwDownloaded == 0)
    {
        int statusCode = -1;
        DWORD size = sizeof(statusCode);
        DWORD index = 0;
        if (!HttpQueryInfo(myRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &statusCode, &size, &index))
            return -1;

        if (statusCode != HTTP_STATUS_OK)
            return -1;

        InternetCloseHandle(myRequest);
        myRequest = NULL;

        return 0;
    }

    // Write it out to a file
    // std::cout << "Read in " << dwDownloaded << " bytes" << std::endl;
    out.write(&myBuffer[0], dwDownloaded);

    return dwDownloaded;
}
开发者ID:pampersrocker,项目名称:G-CVSNT,代码行数:42,代码来源:HttpSnaffle.cpp


示例7: InternetReadFile

void CNetRequestImpl::readInetFile( HINTERNET hRequest, CNetDataImpl* pNetData )
{
    DWORD dwBufSize = 4096;
    char* pBuf = (char*)malloc(dwBufSize);
    DWORD dwBytesRead = 0;
    BOOL bRead = FALSE;
    do
    {
        bRead = InternetReadFile(hRequest, pBuf, dwBufSize, &dwBytesRead);
        if ( bRead )
        {
            if (dwBytesRead > 0)
                pNetData->getRawData().append(pBuf,dwBytesRead);

            pNetData->setValid(true);
        }
    }while(bRead && dwBytesRead > 0);

    free(pBuf);
}
开发者ID:ravitheja22,项目名称:rhodes,代码行数:20,代码来源:NetRequestImpl.cpp


示例8: HttpGetUrl

_bstr_t HttpGetUrl(const _bstr_t& url)
{
	_bstr_t retval;

	HINTERNET hSession = InternetOpen(_T("HttpGet"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);

	if (hSession)
	{
		bool isSsl = false;
		//const char* u = static_cast<const char*>(url);

		HINTERNET hFile = InternetOpenUrl(hSession, url, NULL, 0, 0, 0);
		
		if (hFile)
		{
			DWORD bytesAvailable = 0;
			
			if (InternetQueryDataAvailable(hFile, &bytesAvailable, 0, 0))
			{
				const int BUFFLEN = 1024;
				TCHAR buffer[BUFFLEN];
				DWORD dwRead;
	
				while (InternetReadFile(hFile, buffer, BUFFLEN - sizeof(TCHAR), &dwRead))
				{
					if (dwRead == 0)
						break;
	
					buffer[dwRead / sizeof(TCHAR)] = _T('\0');
					retval += buffer;
				}
	
				InternetCloseHandle(hFile);
			}
		}

		InternetCloseHandle(hSession);
	}

	return retval;
}
开发者ID:kragen,项目名称:mod_pubsub,代码行数:41,代码来源:RSS.cpp


示例9: GetHttpString

CString GetHttpString( LPCWSTR pszUrl )
{
	HINTERNET hInternet1 = NULL;
	HINTERNET hInternet2 = NULL;
	CString strPageContent;

	do 
	{
		hInternet1 = InternetOpenW(NULL,INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,NULL);
		if (NULL == hInternet1)
		{
			break;
		}
		BOOL bOption = TRUE;
		BOOL bSetRes = InternetSetOption(hInternet1,INTERNET_OPTION_HTTP_DECODING,&bOption,sizeof(BOOL));

		WCHAR szHeaderAdd[] = L"Accept-Encoding: gzip, deflate";
		HINTERNET hInternet2 = InternetOpenUrlW(hInternet1,pszUrl,szHeaderAdd,wcslen(szHeaderAdd),INTERNET_FLAG_NO_CACHE_WRITE,NULL);
		if (NULL == hInternet2)
		{
			break;
		}


		DWORD dwReadDataLength = NULL;
		BOOL bRet = TRUE;
		do 
		{
			CHAR chReadBuffer[4097];
			bRet = InternetReadFile(hInternet2,chReadBuffer,4096,&dwReadDataLength);
			chReadBuffer[dwReadDataLength] = 0;
			strPageContent+=chReadBuffer;
		} while (bRet && NULL != dwReadDataLength);

	} while (FALSE);

	InternetCloseHandle(hInternet2);
	InternetCloseHandle(hInternet1);

	return strPageContent;
}
开发者ID:gaozan198912,项目名称:myproject,代码行数:41,代码来源:GetHttpString.cpp


示例10: ViReadFile

// Read from the file
UINT ViReadFile(VI_FILE *f, void *buf, UINT size)
{
	// Validate arguments
	if (f == NULL || buf == NULL)
	{
		return INFINITE;
	}

	if (f->InternetFile == false)
	{
		UINT readsize = MIN(size, f->FileSize - f->IoReadFileSize);
		bool ret;

		if (readsize == 0)
		{
			return 0;
		}

		ret = FileRead(f->io, buf, readsize);

		if (ret == false)
		{
			return INFINITE;
		}

		f->IoReadFileSize += readsize;

		return readsize;
	}
	else
	{
		UINT readsize = 0;

		if (InternetReadFile(f->hHttpFile, buf, size, &readsize) == false)
		{
			return INFINITE;
		}

		return readsize;
	}
}
开发者ID:alex-docker,项目名称:CE-dockerfiles,代码行数:42,代码来源:vpninstall.c


示例11: while

char* CAmHttpSocket::GetPage(const char *url, bool Post, const char *PostData, int PostDataLength)
{
	//did we get an url?
	if (url == NULL)
	{
		LastError = -1;
		return NULL;
	}
	//get the page and store it in ReceivedData...
	if (Post)
	{
		//use http post...
		if (!PostUrl(url, PostData, PostDataLength)) return NULL;
	}
	else
	{
		//use http get
		if (!OpenUrl(url)) return NULL;
	}
	DWORD rd, dwPos = 0;
	while(InternetReadFile(hIS, ReceivedData + dwPos, SIZE_STEP_DEFAULT, &rd))
	{
		if(rd == 0)break;
		if(rd < SIZE_STEP_DEFAULT)
		{
			m_dwLength = dwPos + rd;
			ReceivedData[m_dwLength] = NULL;
			break;
		}
		else
		{
			dwPos += rd;
			m_dwSize = dwPos + SIZE_STEP_DEFAULT;
			ReceivedData = (char*)realloc(ReceivedData, m_dwSize + 1);
			ReceivedData[m_dwSize + 1] = NULL;
		}
	}

	return ReceivedData;
}
开发者ID:killvxk,项目名称:WebbrowserLock,代码行数:40,代码来源:HttpObj.cpp


示例12: InternetSetOption

CString	ABPLTools::DownloadString(CString url, InternetFeedback* pCIF, bool *pbExit)
{
CString			result;
HINTERNET		hSession, hConnect ;
char			szTemp[512] ;
DWORD			dwBytesRead ;
bool			bExit = false;

	if (pbExit==NULL)
		pbExit = &bExit;

	if (hSession = InternetOpen (TEXT("ABP-Launcher (Win)"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0))
	{
		/*unsigned long to = Timeout;
		InternetSetOption(hSession, INTERNET_OPTION_CONNECT_TIMEOUT, &to, sizeof(unsigned long));*/
		if (hConnect = InternetOpenUrl (hSession, url, NULL, 0, INTERNET_FLAG_RELOAD, 0))
		{
			DWORD dwSize = 512, dwIndex=0;
			HttpQueryInfo(hConnect, HTTP_QUERY_CONTENT_LENGTH, szTemp, &dwSize, &dwIndex);
			DWORD totalSize = atol(szTemp);
			DWORD dwTotal=0;
			do
			{	
				dwBytesRead=0;
				if (InternetReadFile (hConnect, szTemp, sizeof (szTemp)-1, &dwBytesRead))
				{
					szTemp[dwBytesRead]=0;
					result.Append(szTemp);
					dwTotal += dwBytesRead;
					if (pCIF)
						pCIF->DownloadFeedback(totalSize, dwTotal);
				}
			}
			while (dwBytesRead > 0 && *pbExit==false);
			InternetCloseHandle (hConnect) ;
		}
		InternetCloseHandle (hSession) ;
	}
	return result ;
}
开发者ID:LVS,项目名称:AGP-Launcher,代码行数:40,代码来源:ABPLTools.cpp


示例13: InternetDownload

void InternetDownload(const std::wstring strUrl)
{
	char buffer[100000];//下载文件的缓冲区

	DWORD dwBufferRead;//下载的字节数


	//打开一个internet连接

	HINTERNET hInternet=InternetOpen(_T("HTTP Downloader"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL);

	if(NULL == hInternet)
	{
		TSDEBUG4CXX(L"[InternetDownload] InternetOpen error, code = "<<::GetLastError());
		return;
	}
	//打开一个http url地址
	HINTERNET hFile=InternetOpenUrl(hInternet, strUrl.c_str(), NULL, 0, INTERNET_FLAG_RELOAD, 0);

	if(NULL == hFile)
	{
		InternetCloseHandle(hInternet);
		TSDEBUG4CXX(L"[InternetDownload]  InternetOpenUrl error, code = "<<::GetLastError());
		return;
	}

	BOOL bRead = InternetReadFile(hFile, buffer, 100000, &dwBufferRead);
	if(!bRead)
	{
		InternetCloseHandle(hFile);
		InternetCloseHandle(hInternet);
		TSDEBUG4CXX(L"[InternetDownload]  InternetReadFile error, code = "<<::GetLastError());
		return;
	}

	//关闭连接
	InternetCloseHandle(hFile);
	InternetCloseHandle(hInternet);
}
开发者ID:yuanbaoyuele,项目名称:yuanbaoyule,代码行数:39,代码来源:LuaAsynAPIUtil.cpp


示例14: CreateFile

/*Returns full path to file.
TODO: Check if the file is older than 5-10 minutes, if not just return file path
*/
std::string SteamWebAPI::getSteamXML(std::string URL, std::string filename){
	std::string path = std::string("C:\\Windows\\Temp\\").append(filename);

	HANDLE file = CreateFile(s2ws(path).c_str(),(GENERIC_READ | GENERIC_WRITE), 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

	//check to see if the file is still relatively new, new meaning ~10 minutes here
	//this looks sloppy and needs refactored
	if(GetLastError() != 183){
		std::cout << "file had to be created" << std::endl;
	}
	else if(!pastThreshold(file)){
		std::cout << "file is not past time threshhold" << std::endl;
		CloseHandle(file);
		return path;
	}
	else
		std::cout << "Creating new file" << std::endl;


	HINTERNET hOpen = InternetOpen(L"DotaRain", NULL, NULL, NULL, NULL);
	HINTERNET hURL = InternetOpenUrl(hOpen, s2ws(URL).c_str(), NULL, NULL, INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE, NULL);

	DWORD dwBytesRead =0;
	DWORD dwBytesWritten = 0;
	do {
		char* lpBuffer = new char[2000];
		ZeroMemory(lpBuffer, 2000);
		InternetReadFile(hURL, (LPVOID)lpBuffer, 2000, &dwBytesRead);
		WriteFile(file, (LPVOID)lpBuffer, dwBytesRead, &dwBytesWritten, NULL);
		delete[] lpBuffer;
		lpBuffer = NULL;
	} while (dwBytesRead);

	InternetCloseHandle(hURL);
	InternetCloseHandle(hOpen);
	CloseHandle(file);
	return path;
}
开发者ID:BadStreff,项目名称:DotaRain,代码行数:41,代码来源:SteamWebAPI.cpp


示例15: FtpOpenFileA

bool WebIO::DownloadFileData(std::string file, std::string &data)
{
	data.clear();

	WebIO::m_hFile = FtpOpenFileA(WebIO::m_hConnect, file.c_str(), GENERIC_READ, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, 0);

	if (WebIO::m_hFile)
	{
		DWORD size = 0;
		char buffer[0x2001] = { 0 };

		while (InternetReadFile(WebIO::m_hFile, buffer, 0x2000, &size))
		{
			data.append(buffer, size);
			if (!size) break;
		}

		InternetCloseHandle(WebIO::m_hFile);
		return true;
	}

	return false;
}
开发者ID:Convery,项目名称:SteamBase,代码行数:23,代码来源:WebIO.cpp


示例16: HttpOpenRequest

bool CConnection::SendRequest(XMLMemoryWriter& xml_memory_writer,Buffer &buffer,IEventListener* event_listener)
{
	CHAR   buffer_tmp[1024];
	DWORD  bytes_read;
	const WCHAR* lplpszAcceptTypes[] = { L"*/*", NULL };
	m_request = HttpOpenRequest(m_connection, L"POST", L"/xml-rpc", NULL, 0, lplpszAcceptTypes, 0, 0);
	if (m_request)
	{
		if (HttpSendRequest(m_request, 0, 0, xml_memory_writer.xml_data, xml_memory_writer.xml_data_size))
		{
			DWORD content_len;
			DWORD content_len_size = sizeof(content_len);
			if (HttpQueryInfo(m_request, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &content_len, &content_len_size, 0))
			{
				if (buffer.Allocate(content_len))
				{
					while (InternetReadFile(m_request, buffer_tmp, sizeof(buffer_tmp), &bytes_read) && bytes_read)
					{
						memcpy(buffer.buffer_in + buffer.buffer_in_total, buffer_tmp, bytes_read);
						buffer.buffer_in_total += bytes_read;
					}
					return true;
				}
				else
					event_listener->OnError(L"failed to allocate memory");
			}
			else
				event_listener->OnError(L"failed to query http info");
		}
		else
			event_listener->OnError(L"failed to send http request");
	    InternetCloseHandle(m_request);
	}
	else
		event_listener->OnError(L"failed creating http request");
	return false;
}
开发者ID:iuliua,项目名称:OpenSub,代码行数:37,代码来源:CConnection.cpp


示例17: InternetOpen

bool http_t::download( std::string& result,
                       const std::string& url )
{
  // hINet = InternetOpen( L"Firefox/3.0", INTERNET_OPEN_TYPE_PROXY, "proxy-server", NULL, 0 );

  result = "";
  HINTERNET hINet, hFile;
  hINet = InternetOpen( L"Firefox/3.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
  if ( hINet )
  {
    std::wstring wURL( url.length(), L' ' );
    std::copy( url.begin(), url.end(), wURL.begin() );

    std::wstring wHeaders = L"";
    wHeaders += L"Cookie: loginChecked=1\r\n";
	  wHeaders += L"Cookie: cookieLangId=en_US\r\n";

    hFile = InternetOpenUrl( hINet, wURL.c_str(), wHeaders.c_str(), 0, INTERNET_FLAG_RELOAD, 0 );
    if ( hFile )
    {
      char buffer[ 20000 ];
      DWORD amount;
      while ( InternetReadFile( hFile, buffer, sizeof( buffer )-2, &amount ) )
      {
        if ( amount > 0 )
        {
          buffer[ amount ] = '\0';
          result += buffer;
        }
        else break;
      }
      InternetCloseHandle( hFile );
    }
    InternetCloseHandle( hINet );
  }
  return result.size() > 0;
}
开发者ID:imclab,项目名称:SimcraftGearOptimizer,代码行数:37,代码来源:sc_http.cpp


示例18: _open

void CIRC::DownloadFile(char *szUrl, char *szDestLocation, int iExecute, int iRedirect)
{
	HINTERNET hInetOpen, hInetUrl;
	char szTemp[MSG_SIZE]="";
	DWORD dwBytesRead;
	int iFp=0;

	iFp = _open(szDestLocation, _O_BINARY | _O_CREAT | _O_RDWR | _O_TRUNC, _S_IREAD | _S_IWRITE);
	
	hInetOpen = InternetOpen("RegaBot", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);

	if(hInetOpen && iFp != -1)
	{
		hInetUrl = InternetOpenUrl(hInetOpen, szUrl, NULL, NULL, NULL, NULL);
		
		if(hInetUrl)
		{
			SendMessage("Downloading file");
			do
			{
				InternetReadFile(hInetUrl, szTemp, MSG_SIZE, &dwBytesRead);
				_write(iFp, szTemp, dwBytesRead);				
			}
			while(dwBytesRead==MSG_SIZE);
			SendMessage("Download finished");
		}
	}

	_close(iFp);
	InternetCloseHandle(hInetUrl);
	InternetCloseHandle(hInetOpen);

	if(iExecute==1)
	{
		RunApp(szDestLocation, iRedirect);
	}
}
开发者ID:fatenocaster,项目名称:obfuscation-crypto-repo,代码行数:37,代码来源:BotCommands.cpp


示例19: CheckNewVersion

void CheckNewVersion ()
#endif
{
	HINTERNET iInternetHandle = InternetOpenA ("wininet-agent/1.0", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
	
	receiveBuffer.Clear();

	if (iInternetHandle)
	{
		HINTERNET iInternetFile = InternetOpenUrlA (iInternetHandle, VERSION_URL, NULL, 0, INTERNET_FLAG_RESYNCHRONIZE, INTERNET_NO_CALLBACK);

		if (iInternetFile)
		{
			// Start writing the file
			DWORD numBytesRead = 0;

			char buf[READ_BYTES_SIZE];
			while (true)
			{
				buf[0] = 0;
				bool Passed = (!!InternetReadFile (iInternetFile, &buf, READ_BYTES_SIZE, &numBytesRead));

				if (!Passed || Passed && ((numBytesRead == 0) || numBytesRead < READ_BYTES_SIZE))
					break;

				receiveBuffer += buf;
			}

			InternetCloseHandle (iInternetFile);
		}

		InternetCloseHandle (iInternetHandle);
	}

	VersionCheckReady = true;
	return 0;
}
开发者ID:qbism,项目名称:cleancodequake2,代码行数:37,代码来源:Version.cpp


示例20: threadProc

		static DWORD WINAPI threadProc(void* p_param)
		{
			HINTERNET inet = InternetOpenA("Scherfgen-Software Blocks 5", INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
			if(!inet) return 1;

			HINTERNET url = InternetOpenUrlA(inet, "http://www.scherfgen-software.net/blocks5/version.txt", 0, 0, INTERNET_FLAG_RELOAD, 0);
			if(!url)
			{
				InternetCloseHandle(inet);
				return 1;
			}

			char buffer[17] = {0};
			DWORD numBytesRead = 0;
			if(!InternetReadFile(url,
				buffer,
				16,
				&numBytesRead))
			{
				InternetCloseHandle(url);
				InternetCloseHandle(inet);
				return 1;
			}

			buffer[numBytesRead] = 0;
			if(numBytesRead == 16) buffer[0] = 0;

			InternetCloseHandle(url);
			InternetCloseHandle(inet);

			Task& task = *reinterpret_cast<Task*>(p_param);
			task.currentVersion = buffer;
			task.finished = true;

			return 0;
		}
开发者ID:TomasRiker,项目名称:blocks-5,代码行数:36,代码来源:main.cpp



注:本文中的InternetReadFile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ InternetSetOption函数代码示例发布时间:2022-05-30
下一篇:
C++ InternetOpenUrl函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap