WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WinInet
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

iFtpCmd RETR Crash on Windows 7 32-bit WinInet Only

 Keywords: iFtpCmd RETR Crash GPF Hang Windows 7 32-bit WinInet

Question:

The 32-bit WinInet Extender version 44081 is crashing on the iFtpCmd RETR statement.
;RETR
; Syntax: RETR remote-filename
; Begins transmission of a file from the remote host. Must be preceded by either a PORT command or a PASV command to indicate where the server should send data.
If WinMetrics(-2) == 3 Then AddExtender("WWINT64I.DLL") ; 64-bit
Else AddExtender("WWINT44I.DLL") ; 32-bit

FTP_Site = "www.myftpserver.com"
FTP_Username = "Fred"
FTP_Password = "****"
FTP_DIR = '/usr/home/fred/'
remotefile = 'Biglist.txt'



;Create Connection
tophandle=iBegin(0,"","")

conhandle=iHostConnect(tophandle, FTP_Site, @FTP, FTP_Username, FTP_Password)
If conhandle==0
  Pause("ERROR: Unable to connect to host ",iGetResponse())
  Exit
EndIf

;***************************************************************************
;**
;** CWD command
;**
;***************************************************************************
;CWD command
cmdhandle=iFtpCmd(conhandle,"CWD",FTP_DIR,@BINARY)
Display(2,'CWD',iGetResponse())
If cmdhandle==0
   err=iGetResponse()
   Message("iFtpCmd Error",err)
   iClose(cmdhandle)
   iClose(conhandle)
   iClose(tophandle)
   Exit
EndIf

;***************************************************************************
;**
;** PASV command
;**
;***************************************************************************
cmdhandle=iFtpCmd(conhandle,"PASV","",@BINARY)
Display(2,'PASV',iGetResponse())
If cmdhandle==0
   err=iGetResponse()
   Message("iFtpCmd Error",err)
   iClose(cmdhandle)
   iClose(conhandle)
   iClose(tophandle)
   Exit
EndIf


;***************************************************************************
;**
;** LIST command iReadData
;**
;***************************************************************************
cmdhandle=iFtpCmd(conhandle,"LIST","",@BINARY)
Display(2,'LIST',iGetResponse())
If cmdhandle==0
   err=iGetResponse()
   Message("iFtpCmd Error",err)
   iClose(cmdhandle)
   iClose(conhandle)
   iClose(tophandle)
   Exit
EndIf
iReadData( cmdhandle, DirScript():'list.txt' )
Pause('LIST - iReadData',FileGet(DirScript():'list.txt'))
iClose(cmdhandle)



;***************************************************************************
;**
;** PWD command
;**
;***************************************************************************
;
cmdhandle=iFtpCmd(conhandle,"PWD","",@BINARY)
Pause('PWD',iGetResponse())
If cmdhandle==0
   err=iGetResponse()
   Message("iFtpCmd Error",err)
   iClose(cmdhandle)
   iClose(conhandle)
   iClose(tophandle)
   Exit
EndIf

;***************************************************************************
;**
;** RETR command
;**
;***************************************************************************
;
cmdhandle=iFtpCmd(conhandle,"RETR",remotefile,@BINARY)
Message("iGetResponse()", iGetResponse())
If cmdhandle==0
   err=iGetResponse()
   Message("iFtpCmd Error",err)
   iClose(cmdhandle)
   iClose(conhandle)
   iClose(tophandle)
   Exit
EndIf

;Find and delete local file
If FileExist(DirScript():remotefile) Then FileDelete(DirScript():remotefile)

;Read RETR results into local file
iReadData( cmdhandle, DirScript():remotefile )


;Clean up
FileDelete(DirScript():'list.txt');Delete LIST results
iClose(cmdhandle)
iClose(conhandle)
iClose(tophandle)


Answer:

This is apparently caused by a Windows bug in the Windows system WinInet.dll. To address the issue we simply wrapped the API call in exception handling and added a new fatal error message to indicate a system error see version 44082. The crash only seems to occur when using the 32-bit version of the extender. One possible workaround is to use the 64-bit WinInet Extender dll.
Article ID:   W17617
Filename:   iFtpCmd RETR Crash on Windows 7 32-bit WinInet Only.txt
File Created: 2017:07:28:13:58:47
Last Updated: 2012:01:25:11:04:55