# Include <stdio. h>
# Include <windows. h>
# Include <wininet. h>
# Define Max size 1024
# Pragma comment (Lib, "wininet. lib ")
Void urlopen (tchar *);
Int main (INT argc, tchar * argv [])
{
Tchar ch [] = text ("http://dt.163.com/images/news/0605/news02053101_5.jpg ");
Urlopen (CH );
Getchar ();
Return 0;
}
Void urlopen (tchar * URL)
{
Hinternet hsession = internetopen (text ("urltest"), internet_open_type_preconfig_with_no_autoproxy, null, null, 0 );
If (hsession! = NULL)
{
Hinternet hhttp = internetopenurl (hsession, URL, null, 0, internet_flag_dont_cache, 0 );
Byte temp [maxsize];
Ulong number = 1;
DWORD written;
Handle hfile;
If (hhttp! = NULL)
{
Wprintf_s (text ("% s \ n"), URL );
hfile = createfile (text ("ysl.jpg"), generic_write, 0, null, create_always, file_attribute_normal, 0);
If (hfile = invalid_handle_value)
{< br> goto hear;
}< br> while (number> 0)
{< br> internetreadfile (hhttp, temp, maxsize-1, & number);
temp [number] = '\ 0';
writefile (hfile, temp, number, & written, null );
}< br> internetclosehandle (hhttp);
hhttp = NULL;
}< br> hear:
closehandle (hfile );
internetclosehandle (hsession);
hsession = NULL;
}< BR >}