Code: Select all
FTPDownload(srv, usr, pwd, rfile, lfile)
{
static a := "jbc-FTP-DL"
if !(m := DllCall("LoadLibrary", "str", "wininet.dll", "ptr")) || !(h := DllCall("wininet\InternetOpen", "ptr", &a, "uint", 1, "ptr", 0, "ptr", 0, "uint", 0, "ptr"))
return 0
if (f := DllCall("wininet\InternetConnect", "ptr", h, "ptr", &srv, "ushort", 21, "ptr", &usr, "ptr", &pwd, "uint", 1, "uint", 0x08000000, "uptr", 0, "ptr")) {
if !(DllCall("wininet\FtpGetFile", "ptr", f, "ptr", &rfile, "ptr", &lfile, "int", 0, "uint", 0, "uint", 0x80000000, "uptr", 0))
return 0, DllCall("wininet\InternetCloseHandle", "ptr", h) && DllCall("FreeLibrary", "ptr", m)
DllCall("wininet\InternetCloseHandle", "ptr", f)
}
DllCall("wininet\InternetCloseHandle", "ptr", h) && DllCall("FreeLibrary", "ptr", m)
return 1
}
This is FTPDownload code from here https://github.com/jNizM/AHK_Scripts/tree/master/src/ftp
I guess author of this code is member of this forum but i'm not sure
the thing is, i need to make timeout if ftpdownload don't end in 2 seconds.
my FTP server is not stable so sometime it needs very long time to end. which is I don't want.
can anybody help?