URLDownloadToFile URLDownloadToCacheFile download file api function difference

  
                  

When you write software, you often need to download files from the Internet (such as upgrading programs or getting program information, etc.). Generally speaking, we use the URLDownloadToFile function. The function prototype is as follows:

HRESULT URLDownloadToFile( LPUNKNOWN pCaller, LPCTSTR szURL, LPCTSTR szFileName, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB );

The three parameters pCaller, dwReserved and lpfnCB are not important, the most important is szURL (to download The file url address) and szFileName (file path and file name to be saved) these two parameters, this function is very convenient, in which language is relatively simple to call, but currently this function has been targeted by a variety of anti-virus software However, a program A that I wrote before will call the function and will be falsely reported by Rising. The reason is that too many downloader programs and Trojan software use this function to download virus files, although my program is harmless but always I was really uncomfortable when I was misreported. I checked msdn and found one. A similar function: URLDownloadToCacheFile, can achieve the same function, but since this function has many calls in IE itself, it will certainly not be killed by mistake. The prototype of this function is as follows:

HRESULT URLDownloadToCacheFile( LPUNKNOWN lpUnkcaller, LPCSTR szURL, LPTSTR szFileName, DWORD dwBufLength, DWORD dwReserved, IBindStatusCallback *pBSC );

is actually very similar to URLDownloadToFile, where the lpUnkcaller, dwReserved and *pBSC parameters can be unspecified, and the necessary parameters are szURL (the url address of the file to be downloaded), szFileName (the pointer to save the file name), dwBufLength (the length of the file name buffer), the function will download the file to the IE cache directory by default (see the function name can be thought of), szFileName Save the file path, you can directly get the szFileName open file when you call it.

Replace the URLDownloadToFile function with URLDownloadToCacheFile and compile the program A I mentioned before. Use VIRUSTOTAL to check the poison, and the false alarm phenomenon can be cancelled.

Copyright © Windows knowledge All Rights Reserved