I need help with this ftp program. I want to do stuff with it but don't know how some stuff works. I don't just want to copy and paste because that teaches me nothing. I really need to get the basics with it. I know how to get it to connect to the host but I get lost when it comes to the password and the username. If you need more code (this is just the main form) or if you want the whole source code, just ask.
Option Explicit
Private PrevButton
Dim Buffer As Integer
Dim States(8) As Com ' initialize the command/reply array
Dim state As Integer
Dim FirstTime As Boolean
Dim CancelFlag As Boolean
Dim akm As Integer
Dim ama As Integer
Dim aza As String
Dim Nr1 As Integer, Nr2 As Integer, num1 As String
Dim LocalIP As String
Dim prts As String
Dim bReplied As Boolean
Dim lTime As Long
Dim MessCnt As Integer
Dim t As Integer
Dim restr As String
Dim numberof As Integer
Dim rmdata As String, trans
Dim x1, y1 As Integer
Sub ButtonUp(Index)
CoolBarImage(Index).Left = CoolBarImage(Index).Left - 10
CoolBarImage(Index).Top = CoolBarImage(Index).Top - 10
Coolbar(Index).Left = Coolbar(Index).Left - 10
Coolbar(Index).Top = Coolbar(Index).Top - 10
Coolbar(Index).Height = Coolbar(Index).Height + 40
Coolbar(Index).Width = Coolbar(Index).Width + 40
End Sub
Sub ButtonDown(Index)
Label3.Caption = ""
CoolBarImage(Index).Left = CoolBarImage(Index).Left + 10
CoolBarImage(Index).Top = CoolBarImage(Index).Top + 10
Coolbar(Index).Left = Coolbar(Index).Left + 10
Coolbar(Index).Top = Coolbar(Index).Top + 10
Coolbar(Index).Height = Coolbar(Index).Height - 40
Coolbar(Index).Width = Coolbar(Index).Width - 40
End Sub
Sub MoveMouse(Index)
If Index <> PrevButton Then
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
End If
PrevButton = Index
Coolbar(Index).BorderStyle = 1
CoolBarImage(Index).Visible = True
End Sub
Function loadSaved() As Boolean
Dim ans As String
chgDirRm = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "RemoteDir")
chgDirLc = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "LocalDir")
ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Usemask")
If ans = "" Or ans = "No" Then
UseMask.Value = 0
End If
If ans = "Yes" Then
UseMask.Value = 1
End If
ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskLocal")
If ans = "" Or ans = "No" Then
chkLc.Value = 0
Remote_mask = ""
End If
If ans = "Yes" Then
chkLc.Value = 1
ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Local")
Local_mask = ans
End If
ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskRemote")
If ans = "" Or ans = "No" Then
chkRm.Value = 0
Remote_mask = ""
End If
If ans = "Yes" Then
chkRm.Value = 1
ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Remote")
Remote_mask = ans
End If
ans = getstring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "PlaySound")
If ans = "" Or ans = "Yes" Then
chkSounds.Value = 1
End If
If ans = "No" Then
chkSounds.Value = 0
End If
End Function
Function SendFile()
Dim temp As String
If doing_multi = False Then
cmdCancel.Enabled = True
End If
If halt_transfer = True Then
Progress.Position = 0
Exit Function
End If
Buffer = 4096
If doing_multi = False Then
Progress.Max = LOF(10)
End If
client.total_size = LOF(10)
multiMove.ProgressBar1.Max = (LOF(10) / 100)
With client
If Buffer > (.total_size - .transferBytesSent) Then
Buffer = (.total_size - .transferBytesSent)
End If
temp = Space$(Buffer)
Get 10, , temp
.transferBytesSent = .transferBytesSent + Buffer
.transferTotalBytes = .transferTotalBytes + Buffer
trans = trans + .transferTotalBytes
If doing_multi = False Then
Progress.Position = .transferTotalBytes
Else
trans = trans / 100
multiMove.ProgressBar1.Position = trans
End If
End With
data.SendData temp
End Function
Sub WaitFor(WaitFor As String)
On Error Resume Next
Do While Response <> WaitFor
DoEvents
Loop
Response = 0
End Sub
Public Sub open_file(filename As String)
On Error GoTo here
If Right(Local_Dir, 2) = "\\" Then
Local_Dir = Mid(Local_Dir, 1, Len(Local_Dir) - 1)
End If
Open (Local_Dir & restr) For Binary Access Write As #1
here:
DoEvents
End Sub
Public Sub Connect()
Dim J
On Error GoTo wrongnum
J = FTPLogin.Host.Text
ServerLog.Clear
state = 0
con.Close
data.Close
Call ipeer
With con
.RemoteHost = J
.RemotePort = FTPLogin.Text1.Text
.LocalPort = Int(Rnd * 99) + 5
.Connect
End With
lTime = 0
While (Not bReplied) And (lTime < 250000)
DoEvents
lTime = lTime + 1
Wend
If lTime >= 250000 Then
MsgBox " Unable to Connect to Host. ": DoEvents
lTime = 0
con.Close
Unload FTPLogin
End If
Exit Sub
wrongnum:
Call Wait(0.25)
J = FTPLogin.Host.Text
ServerLog.Clear
state = 0
con.Close
data.Close
Call ipeer
With con
.RemoteHost = J
.RemotePort = FTPLogin.Text1.Text
.LocalPort = Int(Rnd * 99) + 5
.Connect
End With
lTime = 0
While (Not bReplied) And (lTime < 250000)
DoEvents
lTime = lTime + 1
Wend
If lTime >= 250000 Then
MsgBox " Unable to Connect to Host. ": DoEvents
lTime = 0
con.Close
Unload FTPLogin
End If
Exit Sub
End Sub
Public Sub Disconnect()
ServerLog.Clear
RemoteFiles.Clear
RemoteDirectories.Clear
isit = False
If con.state = sckConnected Then
con.SendData "QUIT" + Chr(13) + Chr(10)
End If
End Sub
Sub ipeer()
On Error GoTo tryagain
data.Close
LocalIP = con.LocalIP
Do Until InStr(LocalIP, ".") = 0
LocalIP = Left(LocalIP, InStr(LocalIP, ".") - 1) + "," + Right(LocalIP, Len(LocalIP) - InStr(LocalIP, "."))
Loop
Randomize Timer
Nr1 = Int(Rnd * 12) + 5
Nr2 = Int(Rnd * 254) + 1
num1 = "PORT " + LocalIP + "," + Trim(str(Nr1)) + "," + Trim(str(Nr2))
prts = num1
data.LocalPort = (Nr1 * 256) + Nr2
data.RemotePort = Trim(str(Nr2)) ' was nr1
data.Close
data.Listen
Exit Sub
tryagain:
Call Wait(0.25)
data.Close
LocalIP = con.LocalIP
Do Until InStr(LocalIP, ".") = 0
LocalIP = Left(LocalIP, InStr(LocalIP, ".") - 1) + "," + Right(LocalIP, Len(LocalIP) - InStr(LocalIP, "."))
Loop
Randomize Timer
Nr1 = Int(Rnd * 12) + 5
Nr2 = Int(Rnd * 254) + 1
num1 = "PORT " + LocalIP + "," + Trim(str(Nr1)) + "," + Trim(str(Nr2))
prts = num1
data.LocalPort = (Nr1 * 256) + Nr2
data.RemotePort = Trim(str(Nr2)) ' was nr1
data.Close
data.Listen
End Sub
Sub sdelem()
akm = RemoteFiles.ListCount - 1
ama = RemoteFiles.SelCount
Dim anss As String
Dim Cancel1 As Boolean
anss = MsgBox("Delete " & ama & " Files on Remote System?", _
vbOKCancel + vbQuestion, "Delete Files"): DoEvents
If anss = vbOK Then
Cancel1 = False
Else
Cancel1 = True
GoTo iohoh
End If
dir_info = ""
Screen.MousePointer = vbHourglass
Dim Y
For Y = 0 To akm
If RemoteFiles.Selected(Y) Then
restr = " " & RemoteFiles.List(Y)
restr = Parse(restr, 1)
con.SendData "DELE " & restr + Chr(13) + Chr(10)
End If
WaitFor (250)
Call Wait(0.125)
Next
doing_multi = False
con.SendData "TYPE A" + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "PWD " + Chr(13) + Chr(10)
Screen.MousePointer = vbDefault
iohoh:
End Sub
Sub delem()
akm = 0
ama = LocalFiles.SelCount
Dim ans As Integer
Dim Cancel As Boolean
ans = MsgBox("Delete " & ama & " Files on Local System?", _
vbOKCancel + vbQuestion, "Delete Files"): DoEvents
If ans = vbOK Then
Cancel = False
Else
Cancel = True
GoTo ohoh
End If
Screen.MousePointer = vbHourglass
Dim Y, ret As Boolean
Y = 0
Do Until Y = LocalFiles.ListCount
If LocalFiles.Selected(Y) Then
ret = ShellDelete(Local_Dir & LocalFiles.List(Y) & Chr(0), FOF_SILENT & FOF_ALLOWUNDO, "")
End If
Y = Y + 1
Call Wait(0.25)
Loop
Screen.MousePointer = 0
RefreshLocal
ohoh:
End Sub
Sub Wait(WaitSeconds As Single)
Dim StartTime As Single
StartTime = Timer
Do While Timer < StartTime + WaitSeconds
DoEvents
Loop
End Sub
Sub RefreshAll()
RefreshLocal
RefreshRemote
End Sub
Sub RefreshLocal()
Screen.MousePointer = vbHourglass
Dim NextLocal As String
Dim FullSpec As String
LocalPWD.Caption = CurDir()
Local_Dir = CurDir()
Local_Dir = Local_Dir & "\"
LocalDirectories.Clear
LocalFiles.Clear
If Len(CurDir()) = 3 Then
FullSpec = CurDir() & "*.*"
Else
FullSpec = CurDir() & "\*.*"
End If
NextLocal = Dir(FullSpec, vbDirectory + vbNormal)
Do While NextLocal <> ""
If Len(CurDir()) = 3 Then
FullSpec = CurDir() & NextLocal
Else
FullSpec = CurDir() & "\" & NextLocal
End If
On Error Resume Next
If (GetAttr(FullSpec) And vbDirectory) = vbDirectory Then
LocalDirectories.AddItem NextLocal
Else
If UseMask.Value = 1 Then
If chkLc.Value = 1 Then
If Len(Local_mask) > 3 Then
masc = "*.*"
LocalFiles.AddItem NextLocal
GoTo doit
End If
masc = Local_mask
If masc = "*.*" Then
LocalFiles.AddItem NextLocal
GoTo doit
End If
If Right(NextLocal, 3) = UCase(masc) Or Right(NextLocal, 3) = LCase(masc) Then
LocalFiles.AddItem NextLocal
GoTo doit
Else
GoTo doit
End If
LocalFiles.AddItem NextLocal
Else
LocalFiles.AddItem NextLocal
End If
Else
LocalFiles.AddItem NextLocal
End If
End If
doit:
NextLocal = Dir
Loop
Screen.MousePointer = vbDefault
End Sub
Sub RefreshRemote()
Screen.MousePointer = vbHourglass
RemoteDirectories.Clear
RemoteFiles.Clear
Screen.MousePointer = vbDefault
End Sub
Private Sub ASCIIMode_Click()
If ASCIIMode.Value = True Then
FTP.BINARY = False
End If
End Sub
Private Sub BinaryMode_Click()
If BinaryMode.Value = True Then
FTP.BINARY = True
End If
End Sub
Private Sub cmdCancel_Click()
If Doing_Upload = True Then
con.SendData "ABOR " + Chr(13) + Chr(10)
halt_transfer = True
Close #10
End If
If Doing_Download = True Then
con.SendData "ABOR " + Chr(13) + Chr(10)
End If
End Sub
Private Sub cmdHelp_Click()
vHelp& = WinHelp(Main.hWnd, App.HelpFile, HELP_INDEX, CLng(0))
End Sub
Private Sub cmdLocal_Click()
Dim ret
ret = BrowseForFolder(Me.hWnd, "Testing")
If ret = "" Then Exit Sub
chgDirLc = ret
End Sub
Private Sub cmdOpt_Click()
If OptFrame.Visible = False Then
OptFrame.Visible = True
Remote.Visible = False
Else
OptFrame.Visible = False
Remote.Visible = True
End If
End Sub
Private Sub cmdRefrLocal_Click()
RefreshLocal
End Sub
Private Sub cmdRefrRemote_Click()
If con.state <> sckConnected Then Exit Sub
On Error GoTo tere
Doing_list = True
dir_info = ""
Call ipeer
con.SendData "TYPE A" + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "PWD " + Chr(13) + Chr(10)
WaitFor (257)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "LIST" + Chr(13) + Chr(10)
Exit Sub
tere:
Doing_list = False
Me.MousePointer = 0
End Sub
Private Sub cmdSave_Click()
If chgDirRm.Text <> "" Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "RemoteDir", chgDirRm.Text)
Else
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "RemoteDir", "")
End If
If chgDirLc.Text <> "" Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "LocalDir", chgDirLc.Text)
Else
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "LocalDir", "")
End If
If UseMask.Value = 1 Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Usemask", "Yes")
If chkLc.Value = 1 Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskLocal", "Yes")
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Local", Local_mask)
Else
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskLocal", "No")
End If
If chkRm.Value = 1 Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskRemote", "Yes")
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Remote", Remote_mask)
Else
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskRemote", "No")
End If
End If
If UseMask.Value = 0 Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "Usemask", "No")
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskLocal", "No")
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "UsemaskRemote", "No")
End If
If chkSounds.Value = 1 Then
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "PlaySound", "Yes")
Else
Call savestring(HKEY_CURRENT_USER, "Software\Homeplay\HPFTP", "PlaySound", "No")
End If
End Sub
Private Sub Command1_Click()
If con.state <> sckConnected Then Exit Sub
On Error GoTo tere
Doing_list = True
dir_info = ""
Call ipeer
con.SendData "TYPE A" + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "PWD " + Chr(13) + Chr(10)
WaitFor (257)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "LIST" + Chr(13) + Chr(10)
RefreshLocal
Exit Sub
tere:
Doing_list = False
Me.MousePointer = 0
End Sub
Private Sub Command2_Click()
On Error GoTo Bottom
frmInfo.txtInf.Text = dir_info
frmInfo.Show
Exit Sub
Bottom:
If Err.Number = 7 Then
MsgBox "Directory to large to list..."
End If
End Sub
Private Sub con_Close()
servu = False
testdir = ""
testfile = ""
Main.Caption = "Dis-Connected"
End Sub
Private Sub con_Connect()
Main.Caption = "Connected - " & con.RemoteHostIP
End Sub
Private Sub con_DataArrival(ByVal bytesTotal As Long)
Dim tmps As String
Dim tri As Integer
Dim tre As String
Dim var As Variant
Dim leng As Integer
Dim ret As Boolean
Dim tmpArray() As String
States(0).BackCode = "220"
States(0).Command = "USER " + FTPLogin.UserName.Text
States(1).BackCode = "331"
States(1).Command = "PASS " + FTPLogin.Password.Text
States(2).BackCode = "230"
States(2).Command = "SYST"
States(3).BackCode = "215"
States(3).Command = "TYPE A"
States(4).BackCode = "200"
If chgDirRm.Text = "" Then
States(4).Command = "PWD "
Else
States(4).Command = ("CWD " + chgDirRm.Text + Chr(13) + Chr(10))
End If
con.GetData tmps, , bytesTotal
leng = Len(tmps)
leng = leng - 4
tri = Len(tmps)
tre = Mid(tmps, 1, (tri - 2))
Response = Mid(tmps, 1, 3)
If Mid(tmps, 1, 3) <> 220 Then ' Server message and Help
If Mid(tmps, 1, 3) = 214 Then
GoTo skip
End If
If Mid(tmps, 1, 3) = 530 Then ' Error message
GoTo skip
End If
If Mid(tmps, 1, 3) = 257 Then ' pwd message
GoTo skip
End If
If Mid(tmps, 1, 3) = 221 Then ' closing message
GoTo skip
End If
ServerLog.AddItem tre
skip:
Else
If Left(tmps, 3) = "220" Then
' Server Welcome Message
If InStr(1, Mid(tmps, 5, leng), vbCrLf) Then
tre = vbCrLf & tre ' add one to beginning
MessCnt = CountStr(tre, " ")
If MessCnt = 0 Then Exit Sub
ret = Parse2Array(tre, tmpArray(), vbCrLf)
For t = 1 To MessCnt
ServerLog.AddItem Mid(tmpArray(t), 2, Len(tmpArray(t)))
If Mid(Mid(tmpArray(t), 2, Len(tmpArray(t))), 1, 10) = "220-Serv-U" Then ' SERV-U sends different path than War-ftp, mine is also compatable to war..., go figure!
servu = True
End If
Next
Else
ServerLog.AddItem tre
End If
End If
End If
If state < 5 Then
If chgDirLc.Text <> "" Then
ChDir chgDirLc.Text
End If
If state = 3 Then
Doing_list = True
Unload FTPLogin
End If
If Left(tmps, 3) = States(state).BackCode Then
Label3.ForeColor = &HFFFFFF
Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
bReplied = True
con.SendData States(state).Command + Chr(13) + Chr(10)
Debug.Print States(state).Command + Chr(13) + Chr(10)
state = state + 1
Exit Sub
Else
End If
End If
If Left(tmps, 4) = "LIST" Then
Doing_list = True
End If
If Left(tmps, 4) = "150 " Then
If InStr(1, tmps, "/bin/ls.") Then
GoTo skipper
End If
If Doing_Download = True Then
client.total_size = Val(Right(tmps, Len(tmps) - InStr(tmps, "(")))
open_file (RemoteFiles.Text)
End If
Exit Sub
skipper:
End If
If Left(tmps, 4) = "214 " Then
ServerLog.AddItem "214 Help:"
ServerLog.AddItem tre
End If
If Left(tmps, 4) = "221 " Then
ServerLog.AddItem "Socket Closed"
ServerLog.AddItem Mid(tmps, 1, Len(tmps) - 2)
state = 0
Do Until con.state <> sckConnected
Call Wait(0.1)
Loop
con.Close
data.Close
End If
If Left(tmps, 4) = "226 " Then
Label3.ForeColor = &HFFFFFF
Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
Close #1
Me.MousePointer = 0
If doing_multi = False Then
client.transferTotalBytes = 0
trans = 0
End If
Progress.Position = 0
ServerLog.AddItem "Done..."
data.Close
cmdCancel.Enabled = False
If halt_transfer = True Then
ServerLog.AddItem "226 Transfer aborted."
halt_transfer = False
Exit Sub
End If
If Doing_list = True Then
Doing_list = False
Exit Sub
End If
If Doing_Upload = True Then
Doing_Upload = False
ServerLog.AddItem "PWD"
con.SendData "TYPE A" + Chr(13) + Chr(10)
WaitFor (200)
con.SendData ("PWD" + Chr(13) + Chr(10))
'If chkSounds.Value = 1 Then
'BeginPlaySound (103)
'End If
Exit Sub
End If
If Doing_Download = True Then
'If chkSounds.Value = 1 Then
'BeginPlaySound (103)
'End If
RefreshLocal
Doing_Download = False
End If
End If
If Left(tmps, 4) = "250 " Then
Label3.ForeColor = &HFFFFFF
Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
If doing_multi = False Then
ServerLog.AddItem "PWD"
con.SendData "TYPE A" + Chr(13) + Chr(10)
WaitFor (200)
con.SendData ("PWD" + Chr(13) + Chr(10))
End If
End If
If Left(tmps, 4) = "257 " Then
Main.Caption = "Doing List"
Label3.ForeColor = &HFFFFFF
Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
dir_info = ""
'If chkSounds.Value = 1 Then
'BeginPlaySound (101)
'End If
If create_dir = True Then
create_dir = False
GoTo jump
End If
If remove_dir = True Then
remove_dir = False
GoTo jump
End If
If servu = False Then
remote_dir = Mid(tmps, 6, Len(tmps) - 30)
RemotePWD.Text = remote_dir
prevPath = Splitpath(remote_dir, 2)
ServerLog.AddItem "257 " & Mid(tmps, 6, Len(tmps) - 30) & " is working directory"
End If
If servu = True Then
If Len(tmps) <= 30 Then
remote_dir = Mid(tmps, 6, 1)
GoTo skiper
End If
remote_dir = Mid(tmps, 7, Len(tmps) - 30)
ServerLog.AddItem "257 " & Mid(tmps, 6, Len(tmps) - 30) & " is working directory"
RemotePWD.Text = remote_dir
prevPath = Splitpath(remote_dir, 2)
GoTo jump
skiper:
RemotePWD.Text = remote_dir
RemoteDirectories.AddItem Mid(tmps, 6, 1)
ServerLog.AddItem "257 " & Mid(tmps, 6, 1) & " is working directory"
End If
jump:
Call ipeer
con.SendData (prts + Chr(13) + Chr(10))
Doing_list = True
Call WaitFor(200)
testdir = ""
testfile = ""
Main.RemoteDirectories.Clear
Main.RemoteFiles.Clear
Main.RemoteDirectories.AddItem ".."
con.SendData ("LIST " + Chr(13) + Chr(10))
End If
If Left(tmps, 4) = "425 " Then
Label3.ForeColor = &HFFFFFF
Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
Me.MousePointer = 0
data.Close
con.SendData "TYPE A" + Chr(13) + Chr(10)
WaitFor (200)
con.SendData ("PWD " + Chr(13) + Chr(10))
End If
If Left(tmps, 4) = "426 " Then
If chkSounds.Value = 1 Then
BeginPlaySound (102)
End If
data.Close
End If
If Left(tmps, 4) = "530 " Then
Label3.ForeColor = &HFF&
Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
con.Close
state = 8
If chkSounds.Value = 1 Then
BeginPlaySound (102)
End If
End If
If Left(tmps, 4) = "550 " Then
If chkSounds.Value = 1 Then
BeginPlaySound (102)
End If
Label3.ForeColor = &HFF&
Label3.Caption = Mid(tmps, 5, Len(tmps) - 5)
Me.MousePointer = 0
If Doing_list = True Then
Doing_list = False
data.Close
Exit Sub
End If
If Doing_Download = True Then
Doing_Download = False
Close #1
data.Close
If multiMove.Visible = True Then
Unload multiMove
End If
Exit Sub
End If
If Doing_Upload = True Then
Close #10
Doing_Upload = False
data.Close
If multiMove.Visible = True Then
Unload multiMove
End If
Exit Sub
End If
If remove_dir = True Then
remove_dir = False
Exit Sub
End If
data.Close
Me.MousePointer = 0
End If
End Sub
Private Sub Coolbar_Click(Index As Integer)
Dim II, size As Long, si As Long, nam As Long
Dim w As Integer
Dim r As Integer
r = Index
Select Case r
Case "0"
If isit = True Then
Beep
GoTo skipper
End If
FTPLogin.Show
skipper:
Case "1"
Call Disconnect
FTPLogin.OK.Enabled = True
FTPLogin.Cancel.Enabled = True
testdir = ""
testfile = ""
Case "2"
On Error GoTo getout
If RemoteFiles.SelCount = 0 Then
Beep
Exit Sub
End If
Main.Caption = "Doing Download"
numberof = 1
trans = 0
client.transferTotalBytes = 0
halt_transfer = False
If RemoteFiles.SelCount = 1 Then
doing_multi = False
Doing_Download = True
restr = " " & RemoteFiles.Text
client.total_size = Parse(restr, 2)
Progress.Max = client.total_size
restr = Parse(restr, 1)
client.File_Name = restr
ServerLog.AddItem "Receiving " & restr & " as " & restr & " (1 of 1)"
con.SendData "TYPE I" + Chr(13) + Chr(10)
Call ipeer
WaitFor (200)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "RETR " & restr + Chr(13) + Chr(10)
ElseIf RemoteFiles.SelCount > 1 Then
For II = 0 To RemoteFiles.ListCount - 1
si = 0
If RemoteFiles.Selected(II) Then
restr = " " & RemoteFiles.List(II)
si = Parse(restr, 2)
si = si / 100
size = size + si
End If
Next
multiMove.ProgressBar1.Max = size
doing_multi = True
For II = 0 To RemoteFiles.ListCount - 1
Doing_Download = True
If RemoteFiles.Selected(II) Then
restr = " " & RemoteFiles.List(II)
client.total_size = Parse(restr, 2)
restr = Parse(restr, 1)
client.File_Name = restr
multiMove.lblNumber = "Moving " & numberof & " of " & RemoteFiles.SelCount & " Files"
multiMove.lblInfo = "Receiving File: " & restr & " " & client.total_size & " Bytes"
multiMove.Show
ServerLog.AddItem "Receiving " & restr & " as " & restr & "(" & numberof & " of " & RemoteFiles.SelCount & ")"
con.SendData "TYPE I" + Chr(13) + Chr(10)
Call ipeer
WaitFor (200)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "RETR " & restr + Chr(13) + Chr(10)
WaitFor (226)
numberof = numberof + 1
Call Wait(0.25)
End If
Next II
multiMove.lblNumber = "Transfer Complete"
multiMove.lblInfo = ""
doing_multi = False
size = 0
Call Wait(0.75)
Unload multiMove
RefreshLocal
End If
Exit Sub
getout:
data.Close
Doing_Download = False
doing_multi = False
Case "3"
If LocalFiles.SelCount = 0 Then
Beep
Exit Sub
End If
Main.Caption = "Doing Upload"
numberof = 1
trans = 0
halt_transfer = False
dir_info = ""
client.transferTotalBytes = 0
Dim inn As Integer
inn = LocalFiles.SelCount
If inn = 1 Then
doing_multi = False
If Right(Local_Dir, 2) = "\\" Then
Local_Dir = Mid(Local_Dir, 1, Len(Local_Dir) - 1)
End If
Open (Local_Dir & LocalFiles.Text) For Binary As #10
With client
.total_size = 0
.transferBytesSent = 0
.currentFile = LocalFiles.Text
End With
Doing_Upload = True
con.SendData "TYPE I" + Chr(13) + Chr(10)
Call ipeer
WaitFor (200)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "STOR " & LocalFiles.Text + Chr(13) + Chr(10)
WaitFor (150)
SendFile
ElseIf LocalFiles.SelCount > 1 Then
If Right(Local_Dir, 2) = "\\" Then
Local_Dir = Mid(Local_Dir, 1, Len(Local_Dir) - 1)
End If
For II = 0 To LocalFiles.ListCount - 1
si = 0
If LocalFiles.Selected(II) Then
Open Local_Dir & LocalFiles.List(II) For Random As #3
si = LOF(3)
Close #3
si = si / 100
size = size + si
End If
Next
multiMove.ProgressBar1.Max = size
doing_multi = True
For II = 0 To LocalFiles.ListCount - 1
Doing_Upload = True
If LocalFiles.Selected(II) Then
restr = LocalFiles.List(II)
client.File_Name = restr
If Right(Local_Dir, 2) = "\\" Then
Local_Dir = Mid(Local_Dir, 1, Len(Local_Dir) - 1)
End If
Open (Local_Dir & restr) For Binary As #10
nam = LOF(10)
multiMove.lblNumber = "Moving " & numberof & " of " & LocalFiles.SelCount & " Files"
multiMove.lblInfo = "Sending File: " & restr & " " & nam & " Bytes"
multiMove.Show
ServerLog.AddItem "Sending " & restr & " as " & restr & " (" & numberof & " of " & inn & ")"
con.SendData "TYPE I" + Chr(13) + Chr(10)
Call ipeer
WaitFor (200)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "STOR " & restr + Chr(13) + Chr(10)
WaitFor (150)
SendFile
WaitFor (226)
numberof = numberof + 1
Call Wait(0.25)
End If
Next II
End If
multiMove.lblNumber = "Transfer Complete"
multiMove.lblInfo = ""
multiMove.ProgressBar1.Position = 0
doing_multi = False
size = 0
Call Wait(0.75)
Unload multiMove
RefreshLocal
Case "4"
AboutBox.Show
Case "5"
RemotePWD.Text = ""
Call Disconnect
Call Wait(0.75)
Me.Hide
Call Wait(1)
End
End Select
End Sub
Private Sub Coolbar_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
ButtonDown (Index)
End Sub
Private Sub Coolbar_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveMouse (Index)
End Sub
Private Sub Coolbar_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
ButtonUp (Index)
End Sub
Private Sub CoolBarImage_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
ButtonDown (Index)
End Sub
Private Sub CoolBarImage_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
MoveMouse (Index)
End Sub
Private Sub CoolBarImage_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
ButtonUp (Index)
End Sub
Private Sub data_Close()
Close #1
data.Close
Me.MousePointer = 0
Progress.Position = 0
Main.Caption = "Connected to " & con.RemoteHostIP
End Sub
Private Sub data_ConnectionRequest(ByVal requestID As Long)
data.Close
data.Accept requestID
End Sub
Private Sub data_DataArrival(ByVal bytesTotal As Long)
Dim k As Integer
cmdCancel.Enabled = True
On Error Resume Next
data.GetData rmdata, , bytesTotal
trans = trans + bytesTotal
client.transferTotalBytes = trans
If doing_multi = False Then
Progress.Position = trans
Else
multiMove.ProgressBar1.Position = (trans / 100)
End If
If Doing_list = True Then
Do Until Response = "226"
dir_info = dir_info & rmdata
Call Wait(0.1)
Loop
Dirlist (dir_info)
Call Wait(0.1)
RemoteDirectories.Refresh
Exit Sub
End If
Put #1, , rmdata
End Sub
Private Sub data_SendComplete()
With client
If .total_size = .transferBytesSent Then
Close #10
data.Close
.transferBytesSent = 0
'If doing_multi = False Then
Progress.Position = 0
cmdCancel.Enabled = False
Else
SendFile
End If
End With
End Sub
Private Sub Drive1_Change()
ChDrive Drive1.Drive
RefreshLocal
End Sub
Private Sub Form_Activate()
If Main.Caption = "Not Connected" Then
GoTo skip
End If
If FirstTime = False Then
FirstTime = True
DoEvents
RefreshAll
End If
skip:
End Sub
Private Sub Form_Load()
App.HelpFile = (App.Path & "\" & "ez-ftp.hlp")
akm = 0
Dim test As Boolean
Me.Move (Screen.Width \ 2) - (Me.Width \ 2), (Screen.Height \ 2) - (Me.Height \ 2)
FirstTime = False
bReplied = False
Cann = False
Doing_list = False
halt_transfer = False
create_dir = False
remove_dir = False
servu = False
loadSaved
Call FormEffect(Main, 144, 135, 60, True, True)
Timer1.Enabled = True
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If x1 >= Me.Width - 485 And x1 <= Me.Width - 300 And y1 >= 75 And y1 <= 255 Then
Me.WindowState = 1
End If
If x1 >= Me.Width - 275 And x1 <= Me.Width - 90 And y1 >= 75 And y1 <= 255 Then
RemotePWD.Text = ""
Call Disconnect
Call Wait(0.75)
Me.Hide
Call Wait(1)
End
End If
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
x1 = X
y1 = Y
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
LocalFiles.ListIndex = -1
RemoteFiles.ListIndex = -1
LocalDirectories.ListIndex = -1
End If
End Sub
Private Sub Form_Resize()
If Me.WindowState = 1 Then Exit Sub
Me.Width = 7290
Me.Height = 7350
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close #1
Me.Hide
If con.state = sckConnected Then
Call Disconnect
Else
con.Close
data.Close
End If
Call Wait(0.75)
Dim Dummy As String
vHelp& = WinHelp(Main.hWnd, Dummy, HELP_QUIT, 0)
End
End Sub
Private Sub Frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub Frame2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub Frame3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub Local_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Local_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub Local_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
LocalFiles.ListIndex = -1
RemoteFiles.ListIndex = -1
LocalDirectories.ListIndex = -1
End If
End Sub
Private Sub LocalCD_Click()
Dim NewDirectory As String
NewDirectory = InputBox$("Enter directory to change to")
If NewDirectory = "" Then
Exit Sub
End If
On Error Resume Next
ChDir NewDirectory
If Err <> 0 Then
MsgBox "Unable to change directory", vbExclamation: DoEvents
Else
RefreshLocal
End If
End Sub
Private Sub LocalDEL_Click()
Dim ret As Boolean
If LocalFiles.SelCount > 1 Then
Call delem
Exit Sub
End If
ret = ShellDelete(Local_Dir & LocalFiles.Text, FOF_ALLOWUNDO, "")
RefreshLocal
End Sub
Private Sub LocalDirectories_DblClick()
If LocalDirectories.ListIndex = -1 Then
Beep
Exit Sub
End If
doing_multi = False
ChDir LocalDirectories.Text
RefreshLocal
End Sub
Private Sub LocalDirectories_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub LocalDirectories_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
RemoteFiles.ListIndex = -1
End Sub
Private Sub LocalFiles_DblClick()
If con.state <> sckConnected Then Exit Sub
On Error GoTo airr
If Right(Local_Dir, 2) = "\\" Then
Local_Dir = Mid(Local_Dir, 1, Len(Local_Dir) - 1)
End If
Open (Local_Dir & LocalFiles.Text) For Binary As #10
doing_multi = False
With client
.total_size = 0
.transferBytesSent = 0
.currentFile = LocalFiles.Text
End With
Doing_Upload = True
con.SendData "TYPE I" + Chr(13) + Chr(10)
Call ipeer
WaitFor (200)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "STOR " & LocalFiles.Text + Chr(13) + Chr(10)
WaitFor (150)
SendFile
Exit Sub
airr:
If Err.Number = 40006 Then
MsgBox " Not Connected ": DoEvents
Else
MsgBox "There was an Error - #" & Err.Number: DoEvents
End If
Close #10
End Sub
Private Sub LocalFiles_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
RemoteFiles.ListIndex = -1
LocalDirectories.ListIndex = -1
End If
End Sub
Private Sub LocalFiles_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub LocalMD_Click()
Dim NewDirectory As String
NewDirectory = InputBox$("Enter new directory name")
If NewDirectory = "" Then
Exit Sub
End If
On Error Resume Next
MkDir NewDirectory
If Err <> 0 Then
MsgBox "Unable to make local directory", vbExclamation: DoEvents
Else
RefreshLocal
End If
End Sub
Private Sub LocalRD_Click()
Dim ans As Integer
Dim Cancel As Boolean
ans = MsgBox("Remove Directory from Local System?", _
vbOKCancel + vbQuestion, "Remove Directory"): DoEvents
If ans = vbOK Then
Cancel = False
Else
Cancel = True
GoTo bherr
End If
If LocalDirectories.ListIndex = -1 Then
Beep
Exit Sub
End If
On Error Resume Next
RmDir LocalDirectories.Text
If Err <> 0 Then
MsgBox "Unable to remove local directory", vbExclamation: DoEvents
Else
RefreshLocal
End If
bherr:
End Sub
Private Sub OptFrame_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub Remote_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Remote_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub Remote_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
LocalFiles.ListIndex = -1
RemoteFiles.ListIndex = -1
LocalDirectories.ListIndex = -1
End If
End Sub
Private Sub RemoteCD_Click()
On Error GoTo cherr
Dim ans As Integer
Dim Cancel As Boolean
ans = MsgBox("Change Directory on Server?", _
vbOKCancel + vbQuestion, "Change Directory"): DoEvents
If ans = vbOK Then
Cancel = False
Else
Cancel = True
GoTo cherr
End If
Dim NewDirectory As String
NewDirectory = InputBox$("Enter directory to change to")
If NewDirectory = "" Then
Exit Sub
End If
If con.state = sckConnected Then
con.SendData ("CWD " & NewDirectory & " " & Chr(13) + Chr(10))
End If
cherr:
End Sub
Private Sub RemoteDEL_Click()
If RemoteFiles.SelCount > 1 Then
doing_multi = True
Call sdelem
Exit Sub
End If
Dim ans As Integer
Dim Cancel As Boolean
If RemoteFiles.ListIndex = -1 Then
MsgBox "You Must Select a File on the Server First!": DoEvents
Exit Sub
End If
doing_multi = False
Dim str1 As String, str2 As String
dir_info = ""
str1 = " " & RemoteFiles.Text
str2 = Parse(str1, 2)
str1 = Parse(str1, 1)
ans = MsgBox("Delete " & str1 & " - " & str2 & " bytes," & " from Server?", _
vbOKCancel + vbQuestion, "Delete File"): DoEvents
If ans = vbOK Then
Cancel = False
Else
Cancel = True
GoTo herr
End If
If con.state = sckConnected Then
Main.Caption = "Doing Delete"
con.SendData "DELE " & str1 + Chr(13) + Chr(10)
End If
herr:
End Sub
Private Sub RemoteDirectories_DblClick()
On Error Resume Next
If con.state <> sckConnected Then Exit Sub
If RemoteDirectories.Text = remote_dir Then Exit Sub
doing_multi = False
Doing_list = True
'MsgBox remote_dir
If RemoteDirectories = ".." Then
Doing_list = True
RemoteFiles.Clear
RemoteDirectories.Clear
con.SendData ("CDUP " + Chr(13) + Chr(10))
Exit Sub
End If
Me.MousePointer = 11
If Mid(RemoteDirectories.Text, 1, 1) = " " Then
remote_dir = Mid(RemoteDirectories.Text, 2, Len(RemoteDirectories.Text) - 1)
Else
remote_dir = RemoteDirectories.Text
End If
On Error Resume Next
con.SendData ("CWD " + remote_dir + Chr(13) + Chr(10))
If Err <> 0 Then
MsgBox "Unable to change directory", vbExclamation: DoEvents
Else
RefreshRemote
End If
End Sub
Private Sub RemoteDirectories_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub RemoteFiles_DblClick()
If con.state <> sckConnected Then Exit Sub
Me.MousePointer = 11
Doing_Download = True
doing_multi = False
restr = " " & RemoteFiles.Text
client.total_size = Parse(restr, 2)
Progress.Max = client.total_size
restr = Parse(restr, 1)
client.File_Name = restr
ServerLog.AddItem "Receiving " & restr & " as " & restr & " (1 of 1)"
Main.Caption = "Doing Download"
con.SendData "TYPE I" + Chr(13) + Chr(10)
Call ipeer
WaitFor (200)
con.SendData prts + Chr(13) + Chr(10)
WaitFor (200)
con.SendData "RETR " & restr + Chr(13) + Chr(10)
End Sub
Private Sub RemoteFiles_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Coolbar(PrevButton).BorderStyle = 0
CoolBarImage(PrevButton).Visible = True
PrevButton = -1
End Sub
Private Sub RemoteFiles_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
LocalFiles.ListIndex = -1
LocalDirectories.ListIndex = -1
End If
End Sub
Private Sub RemoteMD_Click()
On Error GoTo gherr
Dim ans As Integer
Dim Cancel As Boolean
ans = MsgBox("Create Directory on Server?", _
vbOKCancel + vbQuestion, "Create Directory"): DoEvents
If ans = vbOK Then
Cancel = False
Else
Cancel = True
GoTo gherr
End If
Dim NewDirectory As String
NewDirectory = InputBox$("Enter new directory name"): DoEvents
If NewDirectory = "" Then
Exit Sub
End If
create_dir = True
If con.state = sckConnected Then
con.SendData ("MKD " + NewDirectory + Chr(13) + Chr(10))
End If
Exit Sub
gherr:
End Sub
Private Sub RemotePWD_KeyPress(KeyAscii As Integer)
Dim patlen As Integer, truth As String
On Error GoTo bott
If KeyAscii = 13 Then
patlen = Len(remote_dir)
truth = RemotePWD.Text
dir_info = ""
If con.state = sckConnected Then
con.SendData ("CWD " + truth + Chr(13) + Chr(10))
End If
KeyAscii = 0
End If
Exit Sub
bott:
On Error Resume Next
con.SendData ("CDUP " + Chr(13) + Chr(10))
KeyAscii = 0
End Sub
Private Sub RemoteRD_Click()
On Error GoTo aherr
Dim shrt As String
Dim ans As Integer
Dim Cancel As Boolean
If RemoteDirectories.SelCount = 0 Then
MsgBox "You Must Select a Directory on Server First": DoEvents
Exit Sub
End If
shrt = RemoteDirectories.Text
If Mid(shrt, 1, 1) = " " Then
shrt = Mid(shrt, 2, Len(shrt) - 1)
End If
ans = MsgBox("Remove Directory " & shrt & " from Server?", _
vbOKCancel + vbQuestion, "Remove Directory"): DoEvents
If ans = vbOK Then
Cancel = False
Else
Cancel = True
GoTo aherr
End If
remove_dir = True
If con.state = sckConnected Then
con.SendData ("RMD " & shrt + Chr(13) + Chr(10))
End If
Exit Sub
aherr:
End Sub
Private Sub Timer1_Timer()
lblTime.Caption = Time
End Sub
Private Sub Title_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End Sub
Private Sub UseMask_Click()
If UseMask.Value = 1 Then
chkLc.Enabled = True
chkRm.Enabled = True
Local_mask.Enabled = True
Remote_mask.Enabled = True
Else
chkLc.Enabled = False
chkRm.Enabled = False
Local_mask.Enabled = False
Remote_mask.Enabled = False
End If
End Sub
by: mammouthPosted on 2001-02-12 at 13:42:56ID: 5836235
Explanation of some ftp function i will explain you the code tonight
TE E
II ARY
E
II ARY
E
Declare Function FtpCreateDirectory Lib "wininet.dll" Alias "FtpCreateDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
7 hConnect
[in] Valid HINTERNET handle returned by a previous call to InternetConnect using INTERNET_SERVICE_FTP.
7 lpszDirectory
[in] Address of a null-terminated string that contains the name of the directory to create on the remote system. This can be either a fully qualified path or a name relative to the current directory.
Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String) As Boolean
7 hConnect
[in] Valid HINTERNET handle returned by a previous call to InternetConnect using INTERNET_SERVICE_FTP.
7 lpszFileName
[in] Address of a null-terminated string that contains the name of the file to delete on the remote system.
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
7 hConnect
[in] Valid handle to an FTP session returned from InternetConnect.
7 lpszSearchFile
[in] Address of a null-terminated string that specifies a valid directory path or file name for the FTP server's file system. The string can contain wildcards, but no blank spaces are allowed. If the value of lpszSearchFile is NULL or if it is an empty string, it will find the first file in the current directory on the server.
7 lpFindFileData
[out] Address of a WIN32_FIND_DATA structure that receives information about the found file or directory.
7 dwFlags
[in] Unsigned long integer value that contains the flags that control the behavior of this function. This can be a combination of the following values:
INTERNET_FLAG_HYPERLINK
INTERNET_FLAG_NEED_FILE
INTERNET_FLAG_NO_CACHE_WRI
INTERNET_FLAG_RELOAD
INTERNET_FLAG_RESYNCHRONIZ
7 dwContext
[in] Address of an unsigned long integer value that contains the application-defined value that associates this search with any application data. This parameter is used only if the application has already called InternetSetStatusCallback to set up a status callback function.
Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszCurrentDirectory As String, lpdwCurrentDirectory As Long) As Long
7 hConnect
[in] Valid handle to an FTP session.
7 lpszCurrentDirectory
[out] Address of a buffer that receives the current directory string, which specifies the absolute path to the current directory. The string is null-terminated.
7 lpdwCurrentDirectory
[in, out] Address of a variable that specifies the length, in characters, of the buffer for the current directory string. The buffer length must include room for a terminating NULL character. Using a length of MAX_PATH is sufficient for all paths. When the function returns, the variable receives the number of characters copied into the buffer.
Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean
7 hConnect
[in] Valid handle to an FTP session.
7 lpszRemoteFile
[in] Address of a null-terminated string that contains the name of the file to retrieve from the remote system.
7 lpszNewFile
[in] Address of a null-terminated string that contains the name of the file to create on the local system.
7 fFailIfExists
[in] BOOL that indicates whether the function should proceed if a local file of the specified name already exists. If fFailIfExists is TRUE and the local file exists, FtpGetFile fails.
7 dwFlagsAndAttributes
[in] Unsigned long integer value that contains the file attributes for the new file. This can be any combination of the FILE_ATTRIBUTE_* flags used by the CreateFile function. For more information on FILE_ATTRIBUTE_* attributes, see CreateFile in the Platform SDK.
7 dwFlags
[in] Unsigned long integer value that contains the flags that control how the function will handle the file download. The first set of flag values indicates the conditions under which the transfer occurs. These transfer type flags can be used in combination with the second set of flags that control caching.
The application can select one of these transfer type values:
FTP_TRANSFER_TYPE_ASCII
Transfers the file using FTP's ASCII (Type A) transfer method. Control and formatting information is converted to local equivalents.
FTP_TRANSFER_TYPE_BINARY
Transfers the file using FTP's Image (Type I) transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method.
FTP_TRANSFER_TYPE_UNKNOWN
Defaults to FTP_TRANSFER_TYPE_BINARY.
INTERNET_FLAG_TRANSFER_ASC
Transfers the file as ASCII.
INTERNET_FLAG_TRANSFER_BIN
Transfers the file as binary.
The following flags determine how the caching of this file will be done. Any combination of the following flags can be used with the transfer type flag. The possible values are:
INTERNET_FLAG_HYPERLINK
Forces a reload if there was no Expires time and no LastModified time returned from the server when determining whether to reload the item from the network.
INTERNET_FLAG_NEED_FILE
Causes a temporary file to be created if the file cannot be cached.
INTERNET_FLAG_RELOAD
Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.
INTERNET_FLAG_RESYNCHRONIZ
Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP and Gopher resources are reloaded.
7 dwContext
[in] Address of an unsigned long integer value that contains the application-defined value that associates this search with any application data. This is used only if the application has already called InternetSetStatusCallback to set up a status callback function.
Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
7 hConnect
[in] Valid HINTERNET handle to an FTP session.
7 lpszLocalFile
[in] Address of a null-terminated string that contains the name of the file to send from the local system.
7 lpszNewRemoteFile
[in] Address of a null-terminated string that contains the name of the file to create on the remote system.
7 dwFlags
[in] Unsigned long integer value that contains the conditions under which the transfers occur. The application should select one transfer type and any of the flags that control how the caching of the file will be controlled.
The transfer type can be any one of the following values:
FTP_TRANSFER_TYPE_ASCII
Transfers the file using FTP's ASCII (Type A) transfer method. Control and formatting information is converted to local equivalents.
FTP_TRANSFER_TYPE_BINARY
Transfers the file using FTP's Image (Type I) transfer method. The file is transferred exactly as it exists with no changes. This is the default transfer method.
FTP_TRANSFER_TYPE_UNKNOWN
Defaults to FTP_TRANSFER_TYPE_BINARY.
INTERNET_FLAG_TRANSFER_ASC
Transfers the file as ASCII.
INTERNET_FLAG_TRANSFER_BIN
Transfers the file as binary.
The following values are used to control the caching of the file. The application can use one or more of the following values:
INTERNET_FLAG_HYPERLINK
Forces a reload if there was no Expires time and no LastModified time returned from the server when determining whether to reload the item from the network.
INTERNET_FLAG_NEED_FILE
Causes a temporary file to be created if the file cannot be cached.
INTERNET_FLAG_RELOAD
Forces a download of the requested file, object, or directory listing from the origin server, not from the cache.
INTERNET_FLAG_RESYNCHRONIZ
Reloads HTTP resources if the resource has been modified since the last time it was downloaded. All FTP and Gopher resources are reloaded.
7 dwContext
[in] Address of an unsigned long integer value that contains the application-defined value that associates this search with any application data. This parameter is used only if the application has already called InternetSetStatusCallback to set up a status callback.
Declare Function FtpRemoveDirectory Lib "wininet.dll" Alias "FtpRemoveDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
7 hConnect
[in] Valid HINTERNET handle to an FTP session.
7 lpszDirectory
[in] Address of a null-terminated string that contains the name of the directory to remove on the remote system. This can be either a fully qualified path or a name relative to the current directory.
Declare Function FtpRenameFile Lib "wininet.dll" Alias "FtpRenameFileA" (ByVal hFtpSession As Long, ByVal lpszExisting As String, ByVal lpszNew As String) As Boolean
7 hConnect
[in] Valid HINTERNET handle to an FTP session.
7 lpszExisting
[in] Address of a null-terminated string that contains the name of the file that will have its name changed on the remote FTP server.
7 lpszNew
[in] Address of a null-terminated string that contains the new name for the remote file.
Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
7 hConnect
[in] Valid HINTERNET handle to an FTP session.
7 lpszDirectory
[in] Address of a null-terminated string that contains the name of the directory to change to on the remote system. This can be either a fully qualified path or a name relative to the current directory.