WINAPI DllCall Timeout need help Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ppapkor
Posts: 14
Joined: 30 Jan 2019, 03:22

WINAPI DllCall Timeout need help

Post by ppapkor » 11 Apr 2021, 04:38

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
}
[Mod edit: [code][/code] tags added.]

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?
User avatar
boiler
Posts: 16903
Joined: 21 Dec 2014, 02:44

Re: WINAPI DllCall Timeout need help

Post by boiler » 11 Apr 2021, 05:41

ppapkor wrote:
11 Apr 2021, 04:38
I guess author of this code is member of this forum but i'm not sure
Yes, @jNizM is a moderator on this forum. This mention of him may alert him to check out this thread, but that doesn't necessarily mean that he will or that he has time to help with this particular issue.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: WINAPI DllCall Timeout need help  Topic is solved

Post by jNizM » 12 Apr 2021, 02:26

Try this class -> https://github.com/jNizM/Class_FTP
and use while loop on FTP.GetFile
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Post Reply

Return to “Ask for Help (v1)”