新手求教,希望一条一条解释下面的代码
#include <stdio.h>#include <Windows.h>
#include <wininet.h>
#define MAXBLOCKSIZE 1024
#pragma comment (lib, "wininet.lib")
void download(const char*);
int main(int argc, char* argv[]){
download("http://sci.hdu.);
return 0 ;
if(argc > 1){
download((const char*)argv[1]);
}else{
printf("Usage: auto-Update url");
}
return 0;
}
void download(const char *Url)
{
HINTERNET hSession = InternetOpen("RookIE/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hSession != NULL)
{
HINTERNET handle2 = InternetOpenUrl(hSession, Url, NULL, 0, INTERNET_FLAG_DONT_CACHE, 0);
if (handle2 != NULL)
{
printf("%s\n",Url);
byte Temp[MAXBLOCKSIZE];
ULONG Number = 1;
FILE *stream;
if( (stream = fopen( "c:\\1.txt", "wb" )) != 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;
}
}