Results 1 to 6 of 6

Thread: URLDownloadToCacheFile

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Location
    Innsbruck, Austria
    Posts
    14

    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.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Maybe your mean to use the URLDownloadToFile API? I couldn't find a URLDownloadToCacheFile API...

    VB Code:
    1. Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2003
    Location
    Innsbruck, Austria
    Posts
    14
    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

  4. #4
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: URLDownloadToCacheFile

    Hi, I'm like to use this API. Can you post a simple code example showing how to use it? Thanks.

    VBAhack

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2003
    Location
    Innsbruck, Austria
    Posts
    14

    Re: URLDownloadToCacheFile

    Hope this will help:

    VB Code:
    1. Private Declare Function URLDownloadToCacheFile Lib "urlmon" Alias "URLDownloadToCacheFileA" ( _
    2.    ByVal lpUnkcaller As Long, _
    3.    ByVal szURL As String, _
    4.    ByVal szFileName As String, _
    5.    ByVal dwBufLength As Long, _
    6.    ByVal dwReserved As Long, _
    7.    ByVal IBindStatusCallback As Long) As Long
    8.    
    9. Private Const E_FAIL As Long = &H80004005
    10. Private Const E_OUTOFMEMORY As Long = &H8007000E
    11. Private Const S_OK As Long = &H0
    12. Private Const MAX_PATH  As Long = 260
    13.  
    14. Private Function DownloadPic(myUrl As String) As String
    15.    Dim retValue As Long
    16.    Dim localFileName As String
    17.    
    18.    On Error GoTo trackError
    19.      
    20.    'prepare  the  variable  that  will  be  filled  with  the name that the file, once
    21.    'downloaded, receives.
    22.    localFileName = Space$(MAX_PATH)
    23.    
    24.    'if  the url was already downloaded into the cache and exists there, it
    25.    'is not downloaded again. Instead, localFileName receives the name of the file that
    26.    'is already in the Cache
    27.    retValue = URLDownloadToCacheFile(0, myUrl, localFileName, Len(localFileName), 0, 0)
    28.    
    29.    If retValue = S_OK Then
    30.       DownloadPic = Left$(localFileName, InStr(localFileName, vbNullChar) - 1)
    31.    Else
    32.       DownloadPic = vbNullString
    33.    End If
    34.    
    35.    Exit Function
    36.    
    37. trackError:
    38.  
    39. DownloadPic = vbNullString
    40.  
    41. End Function

  6. #6
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    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
  •  



Click Here to Expand Forum to Full Width