Ӧо
APPLICATION RESEARCH OF COMPUTERS
2000 Vol.17 No.3 P.36-37




VBֶ֧ϵInternetؼ
Сܵ
ժҪҪFTPĹܺʵַ˵FTPʵֶϵԭVisual Basic̽˴ֶ֧ϵInternetؼĹ̡
ؼʣϵ Microsoft Internet Transferؼ ActiveXؼ Visual Basic
InternetʹõռͬʱʹFTPļݡͨõص㣬FTPԽԽƵʹáȻΧFTPкܶʵõֳɳѡãûϣԼƺͶƾFTPܵӦáVBMicrosoft Internet TransferؼΪ߹ΪʹõĹ֮һʹûԻڴ˿Լ֧ļӦáVBȴֶ֧ϵĿؼֶ֧ϵInternetؼԱοʹá
1FTPͶϵԭ
FTP(ļЭ)Internetʹ㷺Э֮һʹFTPЭFTPϵ¼ʵļϡءFTPһпͻ/ṹϵͳϵͳɿͻͷϵɣFTPЭڲһɹûʹõļĴͣ磺лĿ¼CDȡļGETļPUTȣļʵʵϾǿͻͷϵFTPЭ໥ͨ(Ӧ)ĽУ˽еFTPϽе¼֤ûݡ
֪FTPжһʵֵģFTPɣ
CD file1ıĿ¼ı䵽file1ָĿ¼
CDUPı䵽Ŀ¼ЧڡCD..
CLOSEرյǰFTPӡ
DELETE file1ɾfile1ָļ
DIR file1Ŀ¼file1ָĿ¼(ͨҪʹԶ﷨)
ûָfile1صǰĿ¼
GET file1 file2file1ָԶļfile2ָ±ļ
LS filelбfile1ָĿ¼(ͨҪʹԶ﷨)
MKDIR file1Ŀ¼filelָĿ¼ǷɹȡûԶ
ϵȨޡ
PUT file1 file2file1ָıļfile2ָԶϡ
PWDӡĿ¼صǰĿ¼
QUITֹǰû
RECV file1 file2file1ָԶļfile2ָıļ
ЧGET
RENAME file1 file2file1ԶļΪfile2ָơ
ɹȡûԶϵȨޡ
RMDIR file1ɾĿ¼ɾfile1ָԶĿ¼ɹȡû
ԶϵȨޡ
SEND file1 file2file1ָıļfile2ָԶϡЧPUT
SIZE file1file1ָĿ¼ĴС
ЩУԶϻȡļõGET⣬õFTPδ룬RESTARTREGET
RESTARTĹûʹGETԶļʹPUTԶļ;·жʱRESTARTϵͳһGETPUTʱϴαжϴ¿ʼϡأӶʹûشͷʼԼļʱ䡣
REGETĹûʹGETԶļĹзжʱʹREGETʵִжϴ¿ʼļ䡣
·ߣʲȶļϴʱԵʮãԽƳֶ֧ϵӦá(עFTPĻʵֵܴ󣬸FTPϵͳֵ֧ҲͬRESTARTREGETʵֽϵͳ֧֣ϵܷʵֻҪԷǷ֧֡򣬼Ҳܹʵֶϵ)
2ֶ֧ϵĿؼ
2.1ؼܵĹ滮
һֶ֧ϵؼӦµĻܡ
STARTCANCELPAUSESTARTʾʼжϺ䣻CANCELҪжϴ䣻PAUSEʾ̣ͣSTARTٴλָ䡣
ԣURLԣʾԶλãFPOSԣʾļԶϵĿ¼λãDIRԣʾļڱػϵ·ļRunCodeԣʾڽļ״̬
¼ɴ֪ͨ¼ȡ
2.2ؼ
a.VB½һActiveXؼ̣ؼ̵Ĺã磺ddxc
b.ڱʾUserControl1FormӽһMicrosoft Internet TransferؼĬΪInet1
c.VBġӳ򡱲˵ѡӳ򿪡ӳڣڡӳбѡVB 6 ActiveXؼӿ򵼡ͬʱڴ½ǽмء͡/жءĸѡѡУȷ
d.VBġӳ򡱲˵ѡӳ򿪡ActiveXؼӿ򵼡ڣڡActiveXؼӿ-ܡѡһ롰ѡӿڳԱڣκβֱѡһ롰ԶӿڳԱڣ¡½ťµĽӿڳԱԶĹӽȥʾֱɡ
e.ʱFormĴ봰ڣԿвִ뱻ӽԱͷидĴժ¼£(б岿дӵĴ룬ಿ[ѡ]ΪÿؼӳԱʱϵͳӵġ)
' Ա:
Dim m_fpos As String
Dim m_url As String
Dim m_dir As String
Dim m_runcode As Integer
'ע⣡Ҫɾ޸бע͵У
' MemberInfo=14
Public Function start( ) As Variant
Dim comstr As String
If m_runcode=2 Then 
' m_runcode2ʾĳ䴦ڱж״̬ comstr=restart" ' restart
лָ䡣 Inet1.Execute url, comstr 
End If
comstr ="get"+m_fpos+" "+m_dir ' ôĲ
Inet1.Execute m_url, comstr ' ʼд
m_runcode=0 ' m_runcode0ʾڽд
End Function
'ע⣡Ҫɾ޸бע͵У
' MemberInfo=14
Public Function cancel( ) As Variant
Dim comstr As String
comstr="close"
Inet1.Execute m_url, comstr ' ֹǰFTP
m_runcode=1 ' Ϊ־ֵ
End Function
'ע⣡Ҫɾ޸бע͵У
'MemberInfo=14
Public Function pause ( ) As Variant
Dim comstr As String
comstr="close"
Inet1.Execute m_url, comstr ' ֹǰFTP
m_runcode=2 ' Ϊ־ֵ
End Function
Private Sub Inet1_StateChanged(By Val State As Integer) 
Inetؼķ״̬Ϊ־ֵ
Dim comstr As String
Select Case State
case icError: ' ䷢˴ж׼¿ʼ
comstr="close"
Inet1.Execute m_url, comstr ' ֹǰFTP 
'һֵֵµһӡ
comstr="restart" 'restartлָ䡣
Inet1.Execute url, comstr
comstr="get" + m_fpos+" "+m_dir ' ôĲ
Inet1.Execute m_url, comstr ' ʼд
Case icResponseCompleted: 'ɹ
comstr="close"
Inet1.Execute m_url, comstr 'ֹǰFTP
m_runcode=1 ' Ϊ־ֵ
End select
End Sub
f.ɺ󣬶б롢ɣɹáӦóͨڳвԸÿؼRunCodeֹͣ
ֻǼ˸ÿؼıƹ̣ʵֻĶϵĹܣҪΪʽʹãдһơ
С(ͬôѧϵ Ϻ 200092)
ܵ(ͬôѧϵ Ϻ 200092)
ο
1 Evangelos Peroutsos, . ʹVisual Basic 5ActiveX. йˮˮ, 1998
ոڣ1999922
