#include <stdio.h>
#include <windows.h>
#include <wininet.h>
#define MAXSIZE 1024
#pragma comment (lib, "Wininet.lib")
void Urlopen (_tchar*);
int _tmain (int argc, _tchar* argv[])
{
Urlopen (_t ("http://coderzh.cnblogs.com"));
return 0;
}
void Urlopen (_tchar* URL)
{
Hinternet hsession = InternetOpen (_t ("Urltest"), internet_open_type_preconfig, NULL, NULL, 0);
if (hsession! = NULL)
{
Hinternet hhttp = InternetOpenUrl (hsession, URL, NULL, 0, Internet_flag_dont_cache, 0);
if (hhttp! = NULL)
{
wprintf_s (_t ("%s\n"), URL);
BYTE Temp[maxsize];
ULONG number = 1;
while (number > 0)
{
InternetReadFile (Hhttp, Temp, MAXSIZE-1, &number);
Temp[number] = ' + ';
printf ("%s", Temp);
}
InternetCloseHandle (hhttp);
Hhttp = NULL;
}
InternetCloseHandle (hsession);
Hsession = NULL;
}
}
Http://www.cnblogs.com/coderzh/archive/2008/11/24/1340134.html
C + + implementation sends HTTP requests