URLDownloadToFile 函数用法
转载来自:https://www.cnblogs.com/Open-Source/p/11003523.html
#include <stdio.h> #include <Urlmon.h> #include <Wininet.h> #pragma comment(lib,"Urlmon.lib") #pragma comment(lib, "Wininet.lib") int main() { CoInitialize(NULL); char *pURL = "http://hi.baidu.com/appview/blog/item/4078622e36e23b2c359bf761.html"; char *pFileName = "D:\\a.html"; char szBuffer[1024*128] = {0}; unsigned long iSize = 0; char szPreCommand[128] = {0}; DeleteUrlCacheEntry(pURL);//清空缓存,否则服务器上的文件修改后,无法下载最新的文件 if (URLDownloadToFile(NULL, pURL, pFileName, 0, NULL)==S_OK) { printf("URLDownloadToFile OK\n"); } else { printf("URLDownloadToFile Fail,Error:%d\n", GetLastError()); } CoUninitialize(); }