Option expedition
Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _ (ByVal sAgent As String, ByVal LAccessType As Long, ByVal sProxyName As String, _ByVal SProxyBypass As String, ByVal lFlags As Long) As Long
Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _ (ByVal hInternetSession As Long, ByVal sServerName As String, _ByVal nServerPort As Integer, ByVal sUsername As String, _ByVal sPassword As String, ByVal lService As Long, _ByVal lFlags As Long , BYVAL LCONTEXT AS Long AS Long
Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _ (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, _ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, _ByVal dwContext As Long ) As boolean
Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" _ (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _ByVal lpszRemoteFile As String, ByVal dwFlags As Long, _ByVal dwContext As Long) As Boolean
Public Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" _ (ByVal hFtpSession As Long, ByVal lpszFileName As String) As Boolean Public Declare Function FtpRenameFile Lib "wininet.dll" Alias "FtpRenameFileA" _ (ByVal hFtpSession As Long, ByVal LPSZEXSITING AS STRING, BYVAL LPSZNEW AS STRING AS Boolean Public Declare Function InternetCloseHandle Lib "Wininet.dll" (Byval Hinet As Long)
Public Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" _ (ByVal hFtpSession As Long, ByVal lpszSearchFile As String, _ lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, _ ByVal dwContent As Long) As Long Public Declare Function InternetFindNextFile Lib " Wininet.dll "Alias" InternetFindNextFilea "_ (Byval Hfind As Long, LPVFNDDATA AS WIN32_FIND_DATA) AS Longconst Internet_Open_Type_Preconfig = 0
Public Type FILETIME dwLowDateTime As Long dwHighDateTime As LongEnd TypePublic Type WIN32_FIND_DATA dwFilAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 As Long dwReserved1 As Long cFileName As String * 260 cAlternate As String * 14End Type
Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _ "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As StringEnd TypePrivate Sub Command1_Click () lnginet = InternetOpen (vbNullString, INTERNET_OPEN_TYPE_PRECONFIG, _ vbNullString, VBnullString, 0 &) IFINET THENTCONN = InternetConnect (LNGINET, IP Address ", 0, _" User Name "," Password ", 1, 0, 0) IF LNGINETCONN THEN BLNRC = FTPGETFILE (LNGINETCONN," Website / Address. ASP "," c: /address.asp ", 0, 0, 1, 0) If blnRC Then MsgBox "download ok !!!" End If InternetCloseHandle lnginetconn InternetCloseHandle lnginet MsgBox "close ok !!!" Else MsgBox "can not connect" End IfElse MsgBox "ftp wrong" End IfEnd Sub