option explicit
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) as integer
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 long
public type filetime
 dwlowdatetime as long
 dwhighdatetime as long
end type
public 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 * 14
end 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 string
end type
private sub command1_click()
lnginet = internetopen(vbnullstring, internet_open_type_preconfig, _
 vbnullstring, vbnullstring, 0&)
if lnginet then
 lnginetconn = internetconnect(lnginet, "ip地址", 0, _
 "用户名", "密码", 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't connect"
 end if
else
 msgbox "ftp wrong"
end if
end sub
private sub command2_click()
dim pdata as win32_find_data
dim lnghinet as long
dim interror as integer
dim strtemp as string
dim blnrc as boolean
pdata.cfilename = string(260, 0)
lnginet = internetopen(vbnullstring, internet_open_type_preconfig, _
 vbnullstring, vbnullstring, 0&)
if lnginet then
 lnginetconn = internetconnect(lnginet, "ip地址", 0, _
 "用户名", "密码", 1, 0, 0)
 if lnginetconn then
 lnghinet = ftpfindfirstfile(lnginetconn, "*.*", pdata, 0, 0)
 strtemp = left(pdata.cfilename, instr(1, pdata.cfilename, string(1, 0), vbbinarycompare) - 1)
 do
 pdata.cfilename = string(260, 0)
 blnrc = internetfindnextfile(lnghinet, pdata)
 if not blnrc then
 exit do
 else
 strtemp = left(pdata.cfilename, instr(1, pdata.cfilename, string(1, 0), vbbinarycompare) - 1)
 end if
 
 loop
 text1.text = strtemp
 end if
 end if
 internetclosehandle lnghinet
 
 internetclosehandle lnginetconn
 internetclosehandle lnginet
 
 
end sub