当前位置: 首页>>代码示例>>C++>>正文


C++ InternetOpenUrl函数代码示例

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


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

示例1: InternetOpen

unsigned long BuscarActualizaciones::ThreadBuscarActualizacion(void *phWnd) {
//	try {
		HINTERNET		Sesion				= InternetOpen(TEXT("BubaTronik"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, INTERNET_INVALID_PORT_NUMBER, 0);
		HINTERNET		Peticion			= InternetOpenUrl(Sesion, TEXT("http://www.devildrey33.es/BubaTronik/VERSION_BUBATRONIK.txt"), NULL, 0, INTERNET_FLAG_RELOAD, 0);
		char			Txt[32]				= "";
		DWORD			BytesLeidos			= 0;
		DWORD			TotalBytesLeidos	= 0;
		DWORD			MaxBuffer			= sizeof(Txt) -1;
		DWL::DWLString	Ret;
		// No se ha encontrado la version :/
		if (Peticion == NULL) {
    		InternetCloseHandle(Sesion);
			return 0;
		}

		BOOL Leido = InternetReadFile(Peticion, Txt, MaxBuffer, &BytesLeidos);
		if (BytesLeidos != 0) {
			Txt[BytesLeidos] = 0;
			Ret += Txt;
	//		ZeroMemory(Txt, sizeof(Txt) * sizeof(char));
		}
		HWND hWndPlayer = reinterpret_cast<HWND>(phWnd);

		if (Ret.Tam() == 0)	{
			InternetCloseHandle(Peticion);
			InternetCloseHandle(Sesion);
			return 0; 
		}
		if (Ret[0] == TEXT('<')) {
			InternetCloseHandle(Peticion);
			InternetCloseHandle(Sesion);
			return 0; // no se ha encontrado el documento
		}
		DWL::DWLString Version;
		Version.sprintf(TEXT("%.02f"), static_cast<float>(APP_NUM_VER));
		// La versión no es la misma, leemos las novedades
		if (Ret.SubStr(0, Version.Tam()) != Version)	{
    	
    		HINTERNET PeticionNovedades	= InternetOpenUrl(Sesion, TEXT("http://www.devildrey33.es/BubaTronik/NOVEDADES_BUBATRONIK.txt"), NULL, 0, INTERNET_FLAG_RELOAD, 0);
			DWORD	  TotalDatos        = 0;
    		DWORD	  Descargado		= 64;
			TCHAR	  TotalDatosStr[64];
			BOOL bRet = HttpQueryInfo(PeticionNovedades, HTTP_QUERY_CONTENT_LENGTH, (LPVOID)TotalDatosStr, &Descargado, (LPDWORD)0);
			if (bRet == TRUE) TotalDatos = _wtol(TotalDatosStr);
			char     *TmpBuffer = new char[TotalDatos + 1];

    		Leido = InternetReadFile(PeticionNovedades, TmpBuffer, TotalDatos, &BytesLeidos);
    		if (BytesLeidos != 0 && BytesLeidos <= TotalDatos) TmpBuffer[BytesLeidos] = 0;
			Sistema.App.PlayerEx.VentanaActualizacion.Novedades(TmpBuffer);
			delete [] TmpBuffer;

			PostMessage(hWndPlayer, MENSAJE_ACTUALIZACION_ENCONTRADA, 0, 0);
		}
		InternetCloseHandle(Peticion);
		InternetCloseHandle(Sesion);
//	}
//	catch (...) {
//	}
	return 0;
}
开发者ID:devildrey33,项目名称:BubaTronik,代码行数:60,代码来源:BuscarActualizaciones.cpp

示例2: DownloadFile

void DownloadFile(char *szUrl, char *szDestLocation)
{
	HANDLE hFile;
	HINTERNET hInetOpen, hInetUrl;
	char szTemp[1024]="";
	DWORD dwBytesRead, dwRead;

	hFile = CreateFile(szDestLocation, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, NULL);
	
	hInetOpen = InternetOpen(" ", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);

	if(hInetOpen && hFile != INVALID_HANDLE_VALUE)
	{
		hInetUrl = InternetOpenUrl(hInetOpen, szUrl, NULL, NULL, NULL, NULL);
		
		if(hInetUrl)
		{
			do
			{
				InternetReadFile(hInetUrl, szTemp, 1024, &dwBytesRead);
				WriteFile(hFile, szTemp, dwBytesRead, &dwRead, 0);
			}
			while(dwBytesRead==1024);
		}
	}

	SetEndOfFile(hFile);

	CloseHandle(hFile);
	InternetCloseHandle(hInetUrl);
	InternetCloseHandle(hInetOpen);

	RunApp(szDestLocation);
}
开发者ID:fatenocaster,项目名称:obfuscation-crypto-repo,代码行数:34,代码来源:SomeFunctions.cpp

示例3: TestURL

void TestURL(CString url, int fullbyte)
{
	TCHAR buffer[HTTP_BUFFER_LEN];//下载文件的缓冲区
	DWORD bytes_read;//下载的字节数
	//打开一个internet连接
	HINTERNET internet=InternetOpen(_T("HTTP"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL);

	if(!internet)
		return;
	//打开一个http url地址

	HINTERNET file_handle=InternetOpenUrl(internet, url, NULL, 0, INTERNET_FLAG_RELOAD, 0);

	if(!file_handle)
		return;
	//从url地址中读取文件内容到缓冲区buffer
	BOOL b = 0;
	int readbyte = 0, time = 0;
	while(readbyte < HTTP_BUFFER_LEN && time < 3000) {
		b = InternetReadFile(file_handle, buffer, 128 , &bytes_read);
		readbyte += bytes_read;
		time++;
	}
	if(!b)
		return;
	//关闭连接
	InternetCloseHandle(internet);
}
开发者ID:william0wang,项目名称:meditor,代码行数:28,代码来源:shared.cpp

示例4: QueryWebPage

const wxString QueryWebPage( const wxString &url )
{
    wxString result;
    HINTERNET hInternet, hFile;
    hInternet = InternetOpen( L"Browser", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL );

    if( hInternet )
    {
        hFile = InternetOpenUrl(
            hInternet,
            url.wc_str(),
            NULL,
            0,
            INTERNET_FLAG_RELOAD,
            0
            );

        if( hFile )
        {
            char buffer[4096];
            DWORD dwRead;
            while( InternetReadFile( hFile, buffer, sizeof(buffer)-1, &dwRead ) )
            {
                if( dwRead == 0 )
                    break;
                buffer[dwRead] = 0;
                result += buffer;
            }
        }
        InternetCloseHandle( hFile );
    }
    InternetCloseHandle( hInternet );

    return result;
}
开发者ID:GeorgeBenjaminBailey,项目名称:ripe,代码行数:35,代码来源:webutility.cpp

示例5: InternetOpen

CString CDialogCheckUpdate::GetLatestVersionInfo(LPCTSTR pstrURL)
{
	HINTERNET hInet = InternetOpen(_T("Check Update"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL);
	HINTERNET hUrl = InternetOpenUrl(hInet, pstrURL, NULL, (DWORD)-1L
		, INTERNET_FLAG_RELOAD | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_NO_CACHE_WRITE |WININET_API_FLAG_ASYNC, NULL);

	char szBuffer[512] = { 0 };
	TCHAR szString[512] = { 0 };
	if(hUrl)
	{
		DWORD dwRead;

		if (InternetReadFile(hUrl, szBuffer, sizeof(szBuffer), &dwRead))
		{
			if (dwRead > 0)
			{
				szBuffer[dwRead] = 0;
				MultiByteToWideChar(CP_ACP,0,szBuffer, strlen(szBuffer)+1, szString, sizeof(szString)/2);
			}
		}
	}

	InternetCloseHandle(hInet);
	return szString;
}
开发者ID:ECNU-ZR,项目名称:physwf-c-lab,代码行数:25,代码来源:DialogCheckUpdate.cpp

示例6: OpenFile

int TInetFile::OpenFile(char*Url)
{
if(hUrl!=NULL)InternetCloseHandle(hUrl);
if(internet!=NULL)InternetCloseHandle(internet);
internet=InternetOpen(Application->Title.c_str(),INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
if(internet==(HANDLE)NULL)
        {
        return 1;
        }
String sU=Url;
sU=sU.UpperCase();
if(sU.Pos("FTP://")) //Это FTP файл
{
Protokol=INET_FILE_FTP;
}else                //Это HTTP файл
{
Protokol=INET_FILE_HTTP;
}
hUrl=InternetOpenUrl(internet,Url,NULL,0,INTERNET_FLAG_EXISTING_CONNECT,0);
if(hUrl==NULL)
        {
        InternetCloseHandle(internet);
        return 2;
        }
Error=false;
CheckFileSize();
Position=0;
return 0;
}
开发者ID:MOROZIL-nic,项目名称:craft,代码行数:29,代码来源:myclasses.cpp

示例7: DownloadURL

BOOL DownloadURL(LPCTSTR szURL, LPCTSTR szFile)
{
    BOOL            bRet = FALSE;
    HINTERNET	    hInternet = NULL, hURL = NULL;
    BYTE            pBuf[DEF_BUF_SIZE] = {0,};
    DWORD           dwBytesRead = 0;
    FILE            *pFile = NULL;
    errno_t         err = 0;

    hInternet = InternetOpen(L"ReverseCore",
                             INTERNET_OPEN_TYPE_PRECONFIG,
                             NULL,
                             NULL,
                             0);
    if( NULL == hInternet )
    {
        OutputDebugString(L"InternetOpen() failed!");
        return FALSE;
    }

    hURL = InternetOpenUrl(hInternet,
                           szURL,
                           NULL,
                           0,
                           INTERNET_FLAG_RELOAD,
                           0);
    if( NULL == hURL )
    {
        OutputDebugString(L"InternetOpenUrl() failed!");
        goto _DownloadURL_EXIT;
    }

    if( err = _tfopen_s(&pFile, szFile, L"wt") )
    {
        OutputDebugString(L"fopen() failed!");
        goto _DownloadURL_EXIT;
    }

    while( InternetReadFile(hURL, pBuf, DEF_BUF_SIZE, &dwBytesRead) )
    {
        if( !dwBytesRead )
            break;

        fwrite(pBuf, dwBytesRead, 1, pFile);
    }

    bRet = TRUE;

_DownloadURL_EXIT:
    if( pFile )
        fclose(pFile);

    if( hURL )
        InternetCloseHandle(hURL);

    if( hInternet )
        InternetCloseHandle(hInternet);

    return bRet;
}
开发者ID:junehappylove,项目名称:GitHub,代码行数:60,代码来源:myhack3.cpp

示例8: InternetOpen

int CZipExists::RemoteFileExists()
{
	int iResult = -1;   // network error
	DWORD dwFilePos = 0;
	HINTERNET hInternet = NULL, hDownload = NULL; 

   CString csUrl = m_csUrl + m_csFileName;
   //AfxMessageBox(csUrl, MB_ICONINFORMATION); 

	hInternet = InternetOpen(_T("Internet"), INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
	if(hInternet != NULL)
	{
		hDownload = InternetOpenUrl(hInternet, csUrl, NULL, 0, INTERNET_FLAG_RELOAD, 0);
		if(hDownload != NULL)
		{
         dwFilePos = InternetSetFilePointer(hDownload, 0, NULL, FILE_BEGIN, NULL);
         iResult = (dwFilePos != (DWORD)-1) ? 1 : 0;
			InternetCloseHandle(hDownload);
		}
      else
      {
         GetInetError();
      }
		InternetCloseHandle(hInternet);
	}
   else
   {
      GetInetError();
   }
	return iResult;
}
开发者ID:identity0815,项目名称:os45,代码行数:31,代码来源:ZipExists.cpp

示例9: InternetOpen

BOOL vmsDownloadForTrafficCollector::MakeWasteDownload(LPCSTR pszUrl)
{
	bool bHTTPS = !strnicmp (pszUrl, "https://", 8);
	HINTERNET hInet = InternetOpen ("Mozilla/4.05 [en] (WinXP; I)", INTERNET_OPEN_TYPE_PRECONFIG,
		NULL, NULL, 0);
	if (hInet == NULL)
		return FALSE;
	HINTERNET hFile = InternetOpenUrl (hInet, pszUrl, NULL, 0, INTERNET_FLAG_IGNORE_CERT_CN_INVALID | 
		INTERNET_FLAG_IGNORE_CERT_DATE_INVALID | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP | 
		INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_UI | INTERNET_FLAG_RELOAD, NULL);
	if (hFile == NULL)
	{
		InternetCloseHandle (hInet);
		return FALSE;
	}
	BYTE ab [1024]; DWORD dw = 0; int iMaxSize = 200*1024/sizeof(ab);
	extern vmsWinInetHttpTrafficCollector _WinInetTrafficCollector;
	while (InternetReadFile (hFile, ab, sizeof (ab), &dw) && dw != 0 && --iMaxSize > 0)
	{
		if (bHTTPS)
			_WinInetTrafficCollector.OnInternetReadFile (hFile, ab, dw);
	}
	InternetCloseHandle (hFile);
	if (bHTTPS)
		_WinInetTrafficCollector.OnInternetCloseHandle (hFile);
	InternetCloseHandle (hInet);
	return TRUE;
}
开发者ID:DragonZX,项目名称:fdm2,代码行数:28,代码来源:vmsDownloadForTrafficCollector.cpp

示例10: InternetOpenUrl

// Checks the current version (curr) against the latest version number stored
// in a file on the Internet.  All numbers are simple integers greater than 100.
// For example, version 4.10 is stored as the 3 digits "410".
// Returns false if a newer version is not available or there is an error, else true.
bool UpdateChecker::UpdateAvailable(int curr)
{
	bool retval = false;

	HINTERNET hint, hurl;
	hint = ::InternetOpen(_T("Update"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
	if (hint == (HINTERNET)0)
		return false;

	hurl = InternetOpenUrl(hint, strUrl, NULL, -1,
	                       INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE |
	                           INTERNET_FLAG_PRAGMA_NOCACHE | WININET_API_FLAG_ASYNC,
	                       NULL);

	char buf[8];            // stores bytes read from current version file on the Internet
	DWORD nread = 0;        // number of bytes read into buf
	if (hurl != (HINTERNET)0 &&	::InternetReadFile(hurl, buf, sizeof(buf)-1, &nread))
	{
		// File (or at least start of file) read OK
		buf[nread] = '\0';    // ensure string is null terminated
		int ver = atoi(buf);  // get version (eg "350" means version 3.50

		if (ver > curr)
			retval = true;

		::InternetCloseHandle(hurl);
	}
	::InternetCloseHandle(hint);

	return retval;
}
开发者ID:Andrew-Phillips,项目名称:HexEdit,代码行数:35,代码来源:UpdateChecker.cpp

示例11: download

void download(const wchar_t *Url, const char *save_as)/*将Url指向的地址的文件下载到save_as指向的本地文件*/
{
	byte Temp[MAXBLOCKSIZE];
	ULONG Number = 1;

	FILE *stream;
	HINTERNET hSession = InternetOpen(L"Test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
	if (hSession != NULL)
	{
		HINTERNET handle2 = InternetOpenUrl(hSession, (LPCWSTR)Url, NULL, 0, INTERNET_FLAG_DONT_CACHE, 0);
		if (handle2 != NULL)
		{

			//if ((stream = fopen_s(save_as, "wb")) != NULL)
			fopen_s(&stream, save_as, "wb");
			if (stream != NULL)
			{
				while (Number > 0)
				{
					InternetReadFile(handle2, Temp, MAXBLOCKSIZE - 1, &Number);

					fwrite(Temp, sizeof(char), Number, stream);
				}
				fclose(stream);
			}

			InternetCloseHandle(handle2);
			handle2 = NULL;
		}
		InternetCloseHandle(hSession);
		hSession = NULL;
	}
}
开发者ID:Damonyg,项目名称:OBS,代码行数:33,代码来源:download.cpp

示例12: linphone_gtk_get_new_version

static int linphone_gtk_get_new_version(const char *version_url, char *version, size_t size){
	DWORD dwDownloaded = 0;
	HINTERNET  hSession = NULL, hConnect = NULL;
	int ret=-1;
	
	hSession=InternetOpen("Linphone",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
	
	if (hSession==NULL) return -1;
	
	hConnect=InternetOpenUrl(hSession,version_url,NULL,0,0,0);
	
	if (hConnect==NULL) {
		InternetCloseHandle(hSession);
		return -1;
	}
	dwDownloaded=0;
	if (InternetReadFile(hConnect,version,size,&dwDownloaded) && dwDownloaded>0){
		version[dwDownloaded]='\0';
		ms_message("Got response: %s", version);
		/*check this not just html containing 404 not found*/
		if (strstr(version,"html")==0)
			ret=0;
	}
	
	// Close any open handles.
	if (hConnect) InternetCloseHandle(hConnect);
	if (hSession) InternetCloseHandle(hSession);
	return ret;
}
开发者ID:AirDev,项目名称:linphone-android,代码行数:29,代码来源:update.c

示例13: InternetOpen

void *http_get(wchar_t *url, u_long *d_size)
{
	HINTERNET h_inet = NULL;
	HINTERNET h_req  = NULL;
	char     *replay = NULL;
	
	do
	{
		h_inet = InternetOpen(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
		if (h_inet == NULL) break;
		
		h_req = InternetOpenUrl(h_inet, url, NULL, 0, INTERNET_FLAGS, 0);
		if (h_req == NULL) break;

		replay = http_receive(h_req, d_size);
	} while (0);

	if (h_req != NULL) {
		InternetCloseHandle(h_req);
	}
	if (h_inet != NULL) {
		InternetCloseHandle(h_inet);
	}
	return replay;
}
开发者ID:hoangduit,项目名称:reactos,代码行数:25,代码来源:http.c

示例14: __open_url

String __open_url (wchar_t const* url)
{
  HINTERNET inet = InternetOpen (L"Firefox/3.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
  if (!inet)
    return "";
  HINTERNET file = InternetOpenUrl (inet, url, NULL, 0, INTERNET_FLAG_RELOAD, 0);
  if (!file)
  {
    InternetCloseHandle (inet);
    return "";
  }
  static char buf[65536];
  String res = "";
  while (true)
  {
    DWORD amount;
    if (!InternetReadFile (file, buf, sizeof buf - 2, &amount))
      break;
    if (amount == 0)
      break;
    buf[amount] = 0;
    res += buf;
  }
  InternetCloseHandle (file);
  InternetCloseHandle (inet);
  return res;
}
开发者ID:NateChambers,项目名称:mule-view,代码行数:27,代码来源:openurl.cpp

示例15: WinInetResource

	WinInetResource(const WinInet& winInet, const std::basic_string<TCHAR>& url, DWORD flags = 0)
	{
		handle_ = InternetOpenUrl(winInet.getHandle(), url.c_str(),
								  NULL, 0, flags, NULL);

		if(handle_ == NULL)
		{
			throw std::exception("InternetOpenUrl failed!");
		}
	}
开发者ID:pindumb,项目名称:temp,代码行数:10,代码来源:GetWanIpAddress.cpp


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