标签:类型 box pre dex == index close bool type
HINTERNET hNet = ::InternetOpen(L"Internet Explorer", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); if (hNet == NULL) { MessageBoxA(NULL, "hNet is NULL", NULL, NULL); } HINTERNET hUrlFile = ::InternetOpenUrlA(hNet, url, NULL, 0, INTERNET_FLAG_RELOAD, 0); if (hUrlFile == NULL) { MessageBoxA(NULL, "hUrlFile is NULL", NULL, NULL); } char buffer[100]; DWORD bufLen = sizeof(buffer); DWORD WIndex = 0; memset(buffer, 0, 100); BOOL bQuery = ::HttpQueryInfoA(hUrlFile, HTTP_QUERY_CONTENT_LENGTH, buffer, &bufLen, &WIndex); dwFileSize = (DWORD)atoi(buffer); InternetCloseHandle(hUrlFile); InternetCloseHandle(hNet);
主要用到HttpQueryInfoA这个函数,第三个参数是用来接收CONTENT_LENGTH的,不过要用字符数组来接收,然后再用atoi转成int类型,这样就能得到网络文件的大小了。
标签:类型 box pre dex == index close bool type
原文地址:https://www.cnblogs.com/sherlock-merlin/p/13176033.html