⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 send1.bas

📁 星子行主机控制系统用于主机管理,方便远程操作,通信等功能.更 方便用于局域网,管理速度快,连接简单方便.注意:星子行连接可用 于带路由主机与带路由主机之间连接,非路由与非路由之间连接.带
💻 BAS
字号:
Attribute VB_Name = "send1"

Option Explicit
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public fileinfo As Long         '记录下次要发送的信息,在完成一次发送操作时检查
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'Public Const HWND_TOPMOST = -1
'Public Const SWP_NOSIZE = &H1

Dim w1 As Long     '为要传输文件的总大小

Public list1path() As String       '为listview1中要传送文件的路径的数组

Public list2path As String   'listview2中的当前文件夹对象路径
Dim list1index As Long    '在listimage 中枚举的进度   改为在数组中的素引

Public desktoppath As String   'list2中桌面的路径
Public x文档 As String         'list2中的文档的路径


Public l2f1 As String            '为被控方IP


Public Sub list1tolist2(er As Integer)   'er用于区别是否为出错处理程序



Form4.Label6.Caption = "总 " & UBound(list1path) + 1 & "个文件,已传输" & list1index & "个文件."



If (list1index <= UBound(list1path)) Then


Call file1(list1path(list1index), list2path)


list1index = list1index + 1

Else

     Form4.Command1.Caption = "完成"

     list1index = 0
     
     
     
      Call refu(list2path, 2)

End If



End Sub






Public Sub file1(path As String, filepath As String)

On Error GoTo er

Open path For Binary As #1


w1 = LOF(1)

If (w1 = 0) Then

fileinfo = 5

Else

fileinfo = 1

End If


Dim path1 As String
path1 = Form3.ListView1.SelectedItem.Key
Dim b2 As String
Dim b1 As Long
Dim b3 As Long
Dim name As String

If (Right(path1, 1) = "\") Then
 
 
path1 = Left(path1, Len(path1) - 1)
 
 
End If

 b2 = "\"
 b1 = Len(path1)
 Do While b1 >= 1
 b1 = b1 - 1
 
 b3 = InStr(b1, path1, b2, 1)
 
 If (b3 > 0) Then
 
 Exit Do
 End If
 
 Loop
 
 
 name = Mid(path, b3 + 1)
 



 
 Form3.Winsock1.SendData "2" & w1 & "." & filepath & name      '发送文件信息
 
 
 


 
 Form4.Label1.Caption = "从“" & path & "”"
 Form4.Label5.Caption = "到 " & Form3.Winsock1.RemoteHostIP & "的“" & filepath & name & "”"
 
 Form4.Label2.Caption = "共" & w1 & "字节"
Form4.Pbar1.Max = w1

 
Exit Sub

er:

MsgBox "读 “" & path & " ”出错,文件拒绝方问或其它原因", 16, "出错"
  
  list1index = list1index + 1
  fileinfo = 0
  Close #1

  Call list1tolist2(1)
 
 list1index = list1index - 1

End Sub


Public Sub file2()

Dim w3 As Long     '记录发送了多少字节数
Dim w2 As Long     '每次发送字节数
w2 = 8191
'w2 = 1048576

Dim file() As Byte



If (w1 <= w2) Then

    ReDim file(w1 - 1)

     Get #1, , file

     Form3.Winsock1.SendData file
     
     Form4.Pbar1.Value = w1
     
     fileinfo = 5
     Form4.Label3.Caption = "已发送 " & w1 & " 字节"
     Form4.Label4.Caption = "剩余 0" & " 字节"

    
Else
  
   Dim w5 As Long
   w5 = Loc(1)
   
       Form4.Pbar1.Value = w5
   
   Form4.Label3.Caption = "已发送 " & w5 & " 字节"
   Form4.Label4.Caption = "剩余 " & w1 - w5 & " 字节"
  
   
' MsgBox w5 & "  " & w2 & "  " & w1
  
  If (w5 + w2 + 1 >= w1) Then
   
  fileinfo = 5
  
  
  ReDim file(w1 - w5 - 1)
  Get #1, , file
  Form3.Winsock1.SendData file
  
  Form4.Pbar1.Value = w1
  
   Form4.Label3.Caption = "已发送 " & w1 & " 字节"
   Form4.Label4.Caption = "剩余 0" & " 字节"
  


  Else
  
  
  ReDim file(w2)
  
  Get #1, , file
  
 
  Form3.Winsock1.SendData file
  
  Form4.Pbar1.Value = w2
  
  
  End If
  
 
End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -