Results 1 to 2 of 2

Thread: ProgressBar - Download File (Solved)

  1. #1

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    ProgressBar - Download File (Solved)

    Ok, I have this code which works perfectly:

    VB Code:
    1. Public ReturnCode As Long
    2.  
    3. Declare Function RegCloseKey Lib "advapi32.dll" (ByVal _
    4. hKey As Long) As Long
    5.  
    6. Declare Function RegOpenKey Lib "advapi32.dll" Alias _
    7. "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As _
    8. String, phkResult As Long) As Long
    9.  
    10. Declare Function RegQueryValueEx Lib "advapi32.dll" Alias _
    11. "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName _
    12. As String, ByVal lpReserved As Long, lpType As Long, _
    13. lpData As Any, lpcbData As Long) As Long
    14.  
    15. Public b() As Byte
    16.  
    17. Sub Download(Inet As Inet, strURL As String, DirDest As String, FileToDownload As String)
    18.     If ActiveConnection Then
    19.         Inet.AccessType = icUseDefault
    20.         strURL = strURL + FileToDownload
    21.         ' Retrieve the file as a byte array.
    22.         b() = Inet.OpenURL(strURL, icByteArray)
    23.        
    24.         Open DirDest + FileToDownload For Binary Access _
    25.         Write As #1
    26.         Put #1, , b()
    27.         Close #1
    28.         MsgBox "Done"
    29.     End If
    30. End Sub
    31.  
    32. Public Function ActiveConnection() As Boolean
    33.     Dim hKey As Long
    34.     Dim lpSubKey As String
    35.     Dim phkResult As Long
    36.     Dim lpValueName As String
    37.     Dim lpReserved As Long
    38.     Dim lpType As Long
    39.     Dim lpData As Long
    40.     Dim lpcbData As Long
    41.     ActiveConnection = False
    42.     lpSubKey = "System\CurrentControlSet\Services\RemoteAccess"
    43.     ReturnCode = RegOpenKey(HKEY_LOCAL_MACHINE, lpSubKey, _
    44.                 phkResult)
    45.     If ReturnCode = ERROR_SUCCESS Then
    46.         hKey = phkResult
    47.         lpValueName = "Remote Connection"
    48.         lpReserved = APINULL
    49.         lpType = APINULL
    50.         lpData = APINULL
    51.         lpcbData = APINULL
    52.         ReturnCode = RegQueryValueEx(hKey, lpValueName, _
    53.         lpReserved, lpType, ByVal lpData, lpcbData)
    54.         lpcbData = Len(lpData)
    55.         ReturnCode = RegQueryValueEx(hKey, lpValueName, _
    56.         lpReserved, lpType, lpData, lpcbData)
    57.         If ReturnCode = ERROR_SUCCESS Then
    58.             'If lpData = 0 Then
    59.             '    ActiveConnection = False
    60.             'Else
    61.             '    ActiveConnection = True
    62.             'End If
    63.             ActiveConnection = lpData
    64.         End If
    65.         RegCloseKey (hKey)
    66.     End If
    67.    
    68. End Function

    The problem is that I'd like to show a ProgressBar and have no clue how to do it. I thought using a Timer and asking for the UBound(b) but doesn't work. Any other ideas?
    Last edited by Mc Brain; May 15th, 2004 at 11:31 AM.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  2. #2

    Thread Starter
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Nevermind... I've figured it out.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

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