WinINet problem with InternetGetLastResponseInfo method. Program ends without error.
Posted on 2007-08-10
I have an unattended process that pull TIFF files from a remote server. I'm using the WinINet.dll for the FTP functions. I use the FtpGetFile function to copy down the file, and if successful, I use the FtpDeleteFile function to remove the file from the source directory. This process has to run thru a proxy server, and during certain periods of heavy usage, the transfers are extremely slow. As a result, the proxy sometimes drops the connection while the file is transferring. Although the transfer completes, the attempt to delete the source file fails because the connection is no longer active. I'm trying to find a reliable way to check the connection following the transfer before attempting the delete, or at least capture the error information when FtpDeleteFile fails.
I'm trying to use the InternetGetLastResponseInfo function to get any useful error numbers and text so that I can proceed accordingly. The following is a copy of my DeleteFile method.:
Public Function DeleteFile(FileToDelete As String) As Boolean
Dim lBuffSize As Long
Dim lError As Long
Dim sErrDesc As String
On Error GoTo ErrorHandler
'Delete the file
If Not FtpDeleteFile(m_hConnection, FileToDelete) Then
'Attempt to retrieve FTP error info.
If Err.LastDllError = ERROR_INTERNET_EXTENDED_ERROR Then
InternetGetLastResponseInfo lError, vbNullString, lBuffSize
sErrDesc = String$(lBuffSize + 1, vbNullChar)
InternetGetLastResponseInfo lError, sErrDesc, lBuffSize '***********
Err.Raise ERR_ON_DELETE, , sErrDesc & vbCr & vbCr & _
"Error occured while trying to delete file " & FileToDelete & " on the remote server."
lError = Err.LastDllError
sErrDesc = GetDLLErrorText(lError)
Err.Raise lError, , sErrDesc
If Err.Number <> 0 Then
m_lErrNum = Err.Number
m_sErrDesc = Err.Description
DeleteFile = False
The variable m_hConnection is the handle returned by the original OpenConnection call. My problem is that the second call to InternetGetLastResponseInfo completely aborts my program (without any error message). In my IDE, when I step thru the execution, same thing. No error, nothing, IDE simply closes.
The WinINet.dll version I have is 6.0.2800.1596. Both my dev machine and the server that the application runs on are Win2000 SP4 (5.0.2195)