Author: crashsky QQ: 36460382
What we see on vckbase is the use of MFCCodeI wrote an API. This Code does not need to use MFC.
// First add the required header file
# Include <stdio. h>
# Include <tchar. h>
# Include <windows. h>
# Include <wininet. h>
// Add the Connection Library
# Pragma comment (Lib, "wininet. lib ")
Int main (INT argc, char * argv [])
{
Printf ("Hello world! ");
Byte Buf [1024];
Tchar path [max_path];
DWORD num;
// Open
Hinternet hinet = internetopen (_ text ("Microsoft Internet Explorer"), internet_open_type_preconfig, null, null, internet_invalid_port_number );
Gettemppath (max_path, PATH );
Strcat (path, "/t.zip ");
// Obtain the file handle
Hinternet hurl = internetopenurl (hinet, _ text ("http://file2.mydrivers.com/display/nvidia_forceware7645.zip"), null, 0, internet_flag_need_file, null );
File * I = fopen (path, "WB ");
// Download the object content from the Internet
While (true = internetreadfile (hurl, Buf, 1024, & num) & num> 0)
{
Fwrite (BUF, 1, num, I );
}
Fclose (I );
// Use the file handle and close the connection
Internetclosehandle (hurl );
Internetclosehandle (hinet );
Return 0;
}