|
-
Mar 21st, 2004, 05:36 AM
#1
Thread Starter
New Member
URLDownloadToCacheFile
Hi,
When I use URLDownloadToCacheFile in my VB Code, I receive the following error:
DLL-Entry Point URLDownloadToCacheFile in URLMON.dll not found
My system is Windows 2000 Professional. urlmon.dll is very likely the most recent version, since it just got updated during a Windows Update (got the same error before the update).
Version Number: 6.0.2800.1400
To make things more confusing: URLDownloadToFile works without a problem, EVEN when I UNREGISTER c:\winnt\system32\urlmon.dll ! How is that possible?
Thanks for your help.
Last edited by 9Mark9; Mar 21st, 2004 at 06:08 AM.
-
Mar 21st, 2004, 07:22 AM
#2
-
Mar 21st, 2004, 07:41 AM
#3
Thread Starter
New Member
Found the solution to my problem. Have to use an alias in the API declaration. This works:
Private Declare Function URLDownloadToCacheFile Lib "urlmon" Alias "URLDownloadToCacheFileA" ( _
ByVal lpUnkcaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwBufLength As Long, _
ByVal dwReserved As Long, _
ByVal IBindStatusCallback As Long) As Long
-
Jan 21st, 2005, 04:26 PM
#4
Fanatic Member
Re: URLDownloadToCacheFile
Hi, I'm like to use this API. Can you post a simple code example showing how to use it? Thanks.
VBAhack
-
Jan 21st, 2005, 04:50 PM
#5
Thread Starter
New Member
Re: URLDownloadToCacheFile
Hope this will help:
VB Code:
Private Declare Function URLDownloadToCacheFile Lib "urlmon" Alias "URLDownloadToCacheFileA" ( _
ByVal lpUnkcaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwBufLength As Long, _
ByVal dwReserved As Long, _
ByVal IBindStatusCallback As Long) As Long
Private Const E_FAIL As Long = &H80004005
Private Const E_OUTOFMEMORY As Long = &H8007000E
Private Const S_OK As Long = &H0
Private Const MAX_PATH As Long = 260
Private Function DownloadPic(myUrl As String) As String
Dim retValue As Long
Dim localFileName As String
On Error GoTo trackError
'prepare the variable that will be filled with the name that the file, once
'downloaded, receives.
localFileName = Space$(MAX_PATH)
'if the url was already downloaded into the cache and exists there, it
'is not downloaded again. Instead, localFileName receives the name of the file that
'is already in the Cache
retValue = URLDownloadToCacheFile(0, myUrl, localFileName, Len(localFileName), 0, 0)
If retValue = S_OK Then
DownloadPic = Left$(localFileName, InStr(localFileName, vbNullChar) - 1)
Else
DownloadPic = vbNullString
End If
Exit Function
trackError:
DownloadPic = vbNullString
End Function
-
Jan 21st, 2005, 08:13 PM
#6
Fanatic Member
Re: URLDownloadToCacheFile
Thanks very much. Tried it and it works, but I was under the mistaken impression that the cache was RAM, not disk. Thus, the only difference between URLDownloadToFile and URLDownloadToCacheFile is that with the former, you need to specify the name/path where you want the file saved. Thanks for helping to make the differences clear.
VBAhack
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|