- InternetOpen
- InternetConnect
- FtpGetFile
- FtpPutFile
- FtpFindFirstFile
- InternetFindNextFile
- InternetCloseHandle
- Open an Internet Connection – This is to initialize the wininet API. One can use any connection name for achieving this
$InternetOpen = DllCall("wininet.dll", "long", "InternetOpen", "str", “My FTP Control”, "long", 1, "str", “”, "str", “”, "long", 0);We can keep the proxy name and proxy bypass as blank. - Connect to the server with the username and password – One need to have a username and password for the same, as well as the handle returned from the previous step
$InternetConnect = DllCall("wininet.dll", "long", "InternetConnect", "long", $InternetOpen, "str", $ServerName, "int", 0, "str", $Username, "str", $Password, "long", 1, "long", 0, "long", 0); Servername, Username, Password need to be provided. - Start the file transfer with FtpGetFile function – Filename and handle needs to be provided as the inputs
$FTPget = DllCall("wininet.dll", "int", "FtpGetFile", "long", $InternetConnect, "str", $RemoteFile, "str", $SaveLocalFile, "int", 0, "long", 0, "long", 0, "long", 0);This would save the file in the local computer with the name as provided in place of variable $SaveLocalFile. - Close both the handles
$CloseCC = DllCall("wininet.dll", "int", "InternetCloseHandle", "int", $InternetOpen)
$CloseCC = DllCall("wininet.dll", "int", "InternetCloseHandle", "int", $InternetConnect)
I have created Ftp client software with the same function, and you can download it freely by clicking here.
If you want to access the code, kindly post a request for it through the comments section. I will share the code with anyone who requires.