6/24/2023 0 Comments Vb6 downloadMsgBox " The buffer length is invalid or there was insufficient memory to complete the operation.", vbCritical + vbOKOnly, " Error while Downloading" End Else ' Debug.Assert False ' Debug.Print "Error occurred " & lRet & " (this is probably a proxy server error)." ![]() InternetGetFile = True Else ' Failed to download file If lRet = E_OUTOFMEMORY Then ' Debug.Print "The buffer length is invalid or there was insufficient memory to complete the operation." If Len(Dir$(sSaveToFile)) Then ' File successfully downloaded LRet = URLDownloadToFile(0&, sURLFileName, sSaveToFile, 0&, 0) If bOverwriteExisting Then If Len(Dir$(sSaveToFile)) ThenĮnd If End If ' Check file doesn't already exist If Len(Dir$(sSaveToFile)) = 0 Then ' Download file LRet = InternetOpen( " ", INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0) ![]() On Error Resume Next ' Create an internet connection Private 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 Private Declare Function InternetOpen Lib " wininet" Alias " InternetOpenA" ( ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long Private Declare Function InternetCloseHandle Lib " wininet" ( ByVal hInet As Long) As Integer Public Function InternetGetFile(sURLFileName As String, sSaveToFile As String, Optional bOverwriteExisting As Boolean = False) As Boolean Dim lRet As Long Const S_OK As Long = 0, E_OUTOFMEMORY = &H8007000EĬonst INTERNET_OPEN_TYPE_PRECONFIG = 0, INTERNET_FLAG_EXISTING_CONNECT = &H20000000Ĭonst INTERNET_OPEN_TYPE_DIRECT = 1, INTERNET_OPEN_TYPE_PROXY = 3 Const INTERNET_FLAG_RELOAD = &H80000000
0 Comments
Leave a Reply. |