Recently made a dynamic library upgrade program, you need to check if there is a new version of the dynamic library. If there is anything, download it. Here is the process of sharing my test downloading the binary file. as follows:
#include
Void Download (const char *);
INT Main (int Argc, char * argv []) {if (argc> 1) {Download (const char *) argv [1]);} else {printf ("usage: auto-update url");} return }
/ ** * Execute file download operation * @Param URL: The target action url * * / 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 ("f: //leadbridge//new.exe", "wb"))! = Null) // This is just a test, so write a dead file path {while (Number> 0) {InternetReadFile (Handle2, Temp, MaxBlocksize - 1, & Number); // FPrintf (stream, (const char *) TEMP); FWRITE (Temp, Sizeof (Char), Number, Stream);} fclose Stream);} InternetCloseHandle (Handle2); Handle2 = NULL;} InternetCloseHandle (HSESSION); hsession = null;}}
This should be the core process of the entire download file. I have read a lot of information before, I'm writing very rich. I hope there are more pursuit of fine mid-in-one people ^ _ ^