Option Strict Off
Option Explicit On
Imports System.Runtime.InteropServices
Module FTPDownload
Dim frm1 As Form1
Private Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInternet As IntPtr) As Boolean
Private Declare Auto Function InternetOpen Lib "wininet.dll" _
(ByVal lpszAgent As String, _
ByVal lAccessType As Integer, _
ByVal lpszProxyName As String, _
ByVal lpszProxyBypass As String, _
ByVal dwFlags As Integer) As IntPtr
Private Declare Auto Function InternetConnect Lib "wininet.dll" _
(ByVal hInternet As IntPtr, _
ByVal lpszServerName As String, _
ByVal nServerPort As Short, _
ByVal lpszUserName As String, _
ByVal lpszPassword As String, _
ByVal dwService As Integer, _
ByVal dwFlags As Integer, _
ByVal dwContext As Integer) As IntPtr
Private Declare Auto Function FtpGetFile Lib "wininet.dll" _
(ByVal hConnect As IntPtr, _
ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, _
ByVal fFailIfExists As Boolean, _
ByVal dwFlagsAndAttributes As Integer, _
ByVal dwFlags As Integer, _
ByVal dwConext As Integer) As Boolean
Private Declare Auto Function FtpPutFile Lib "wininet.dll" _
(ByVal hConnect As IntPtr, _
ByVal lpszLocalFile As String, _
ByVal lpszNewRemoteFile As String, _
ByVal dwFlags As Integer, _
ByVal dwContext As Integer) As Boolean
Dim currentnumber As Integer
Sub Main()
currentnumber = currentnumber + 1
Dim hInet As IntPtr
Dim hConn As IntPtr
hInet = InternetOpen("my ftp", 1, vbNullString, vbNullString, 0)
Console.WriteLine("hInet = {0}", hInet)
hConn = InternetConnect(hInet, "no.prefix.com", 21, "", _
"", 1, 0, 0)
Console.WriteLine("hConn = {0}", hConn)
Console.WriteLine("FtpGetFile Result = {0}", FtpGetFile(hConn, _
"folder/in/ftp.txt", "location\ftp.txt", True, 1, 1, 0))
InternetCloseHandle(hConn)
InternetCloseHandle(hInet)
End Sub