VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Begin VB.Form Form1 
   Caption         =   "zwj局内网共享"
   ClientHeight    =   9300
   ClientLeft      =   225
   ClientTop       =   855
   ClientWidth     =   9465
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   9300
   ScaleWidth      =   9465
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text1 
      Height          =   855
      Left            =   9360
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   9
      Text            =   "Form1.frx":0000
      Top             =   7320
      Visible         =   0   'False
      Width           =   2055
   End
   Begin MSComctlLib.ProgressBar PB1 
      Height          =   255
      Left            =   240
      TabIndex        =   8
      Top             =   8520
      Width           =   8895
      _ExtentX        =   15690
      _ExtentY        =   450
      _Version        =   393216
      Appearance      =   1
   End
   Begin VB.Timer scwjm 
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   9240
      Top             =   2760
   End
   Begin VB.Timer scwj 
      Enabled         =   0   'False
      Interval        =   2000
      Left            =   9240
      Top             =   1800
   End
   Begin MSComctlLib.ImageList ImageList2 
      Left            =   9240
      Top             =   5760
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   50
      ImageHeight     =   50
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   4
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0006
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0E80
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":2C82
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":3AFC
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.TextBox cmmm 
      Height          =   375
      Left            =   1440
      TabIndex        =   4
      Top             =   1320
      Visible         =   0   'False
      Width           =   2055
   End
   Begin VB.Timer gbwj 
      Enabled         =   0   'False
      Interval        =   4000
      Left            =   9240
      Top             =   2280
   End
   Begin MSComDlg.CommonDialog CD1 
      Left            =   9120
      Top             =   1080
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.Timer ssfwq 
      Interval        =   500
      Left            =   11040
      Top             =   840
   End
   Begin VB.Timer wzgd 
      Enabled         =   0   'False
      Interval        =   100
      Left            =   10320
      Top             =   960
   End
   Begin MSWinsockLib.Winsock khd 
      Index           =   0
      Left            =   9240
      Top             =   3240
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin ComctlLib.TreeView TV1 
      Height          =   6615
      Left            =   240
      TabIndex        =   2
      Top             =   1800
      Width           =   8895
      _ExtentX        =   15690
      _ExtentY        =   11668
      _Version        =   327682
      HideSelection   =   0   'False
      Style           =   7
      ImageList       =   "ImageList1"
      Appearance      =   1
   End
   Begin MSComctlLib.Toolbar Toolbar1 
      Align           =   1  'Align Top
      Height          =   1140
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   9465
      _ExtentX        =   16695
      _ExtentY        =   2011
      ButtonWidth     =   1508
      ButtonHeight    =   1958
      Appearance      =   1
      Style           =   1
      ImageList       =   "ImageList2"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   4
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "上传"
            Object.Tag             =   "1"
            ImageIndex      =   1
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "下载"
            Object.Tag             =   "2"
            ImageIndex      =   2
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "刷新"
            Object.Tag             =   "3"
            ImageIndex      =   3
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "取消"
            ImageIndex      =   4
         EndProperty
      EndProperty
      BorderStyle     =   1
   End
   Begin VB.Label Label2 
      Caption         =   "by:zwj qq:133450306"
      Height          =   375
      Left            =   6720
      TabIndex        =   7
      Top             =   1320
      Width           =   1455
   End
   Begin VB.Label l3 
      Caption         =   "Label3"
      Height          =   255
      Left            =   9240
      TabIndex        =   6
      Top             =   1320
      Visible         =   0   'False
      Width           =   495
   End
   Begin VB.Label l2 
      Caption         =   "Label2"
      Height          =   255
      Left            =   8520
      TabIndex        =   5
      Top             =   1320
      Visible         =   0   'False
      Width           =   375
   End
   Begin VB.Label lw 
      Caption         =   "服务器已关闭"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   375
      Left            =   3480
      TabIndex        =   3
      Top             =   1320
      Width           =   2535
   End
   Begin ComctlLib.ImageList ImageList1 
      Left            =   12360
      Top             =   2160
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   50
      ImageHeight     =   50
      MaskColor       =   12632256
      _Version        =   327682
      BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
         NumListImages   =   9
         BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "Form1.frx":4942
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "Form1.frx":6744
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "Form1.frx":8546
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "Form1.frx":A348
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "Form1.frx":C14A
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "Form1.frx":DF4C
            Key             =   ""
         EndProperty
         BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "Form1.frx":FD4E
            Key             =   ""
         EndProperty
         BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "Form1.frx":11B50
            Key             =   ""
         EndProperty
         BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
            Picture         =   "Form1.frx":13952
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.Image Image2 
      Height          =   375
      Left            =   0
      Top             =   0
      Width           =   615
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "全部文件"
      Height          =   180
      Left            =   240
      TabIndex        =   1
      Top             =   1440
      Width           =   720
   End
   Begin VB.Menu bj 
      Caption         =   "bj"
      Begin VB.Menu xz 
         Caption         =   "下载"
      End
      Begin VB.Menu sc 
         Caption         =   "删除"
      End
      Begin VB.Menu cmm 
         Caption         =   "重命名"
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim pds As Boolean
Dim ipsz(256) As String
Dim xhs As Integer
Dim wjcd As Long '定义文件长度
Dim wjmc As String '定义文件名
Dim pdxz As Boolean
Dim xmlb As Long
Dim x As Long
Dim y As Long
Dim sclj As String
Dim scsj() As Byte
Dim zwjs As Integer
Dim sjj As String

Private Sub cmm_Click()
cmmm.Visible = True
cmmm.Left = l2.Caption + 3000
cmmm.Top = l3.Caption + 1600
cmmm.Text = wjmc
End Sub

Private Sub cmmm_KeyPress(KeyAscii As Integer)
Dim sk As String
If KeyAscii = 13 Then '按了回车键
If cmmm.Text = "" Then '是否为空
Beep
Else '是否为空
sk = Trim(cmmm.Text)
cmmm.Visible = False
TV1.Nodes.Item(xmlb).Key = sk
TV1.Nodes.Item(xmlb).Text = sk
khd(xhs).SendData sk & "*" & wjmc
End If '是否为空
End If '按了回车键
End Sub

Private Sub Form_Load()

pds = True
Call tjip '添加ip列表
bj.Visible = False
pdxz = False
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If pds = False Then
wzgd.Enabled = True
End If
End Sub

Private Sub gbwj_Timer()
Close #3
MsgBox "下载完成", vbInformation, "zwj共享"
pdxz = False
gbwj.Enabled = False

End Sub

Private Sub khd_Connect(Index As Integer)
lw.Caption = "成功连接上服务器"
ssfwq.Enabled = False
End Sub

Private Sub khd_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim sj As String, wjznr() As Byte, sccs As Long

If pdxz = False Then '判断是否下载
khd(xhs).GetData sj

If Len(sj) >= 5 Then
Text1.Text = sj
Call xgsj '修改数据
End If

If sj = "否" Then '是否存在文件
MsgBox "该文件已不存在!!", vbInformation, "zwj共享"
End If '是否存在文件



If sj = "是" Then '是否存在文件
MsgBox "删除成功!!", vbInformation, "zwj共享"

TV1.Nodes.Remove xmlb
End If '是否存在文件

If sj = "我是服务" Then '是否为文件名
ssfwq.Enabled = False
'MsgBox xhs
lw.Caption = "成功连接上服务器"

Else '是否为文件名
If Left(sj, 3) = "长度>" Then '获取文件长度
wjcd = Right(sj, Len(sj) - 3)
ReDim wjznr(wjcd)
pdxz = True
gbwj.Enabled = True





End If '获取文件长度




End If '是否为文件名


End If '判断是否下载
If pdxz = True Then '下载文件
khd(xhs).GetData wjznr
Put #3, , wjznr
End If '下载文件


If sj = "可以了" Then '可以上传文件数据
Open sclj For Binary As #4
Get #4, , scsj
Close #4
khd(xhs).SendData scsj

End If '可以上传文件数据
End Sub

Private Sub khd_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Index = xhs
MsgBox "服务器已关闭"
End Sub

Private Sub khd_SendComplete(Index As Integer)
MsgBox "传输完成！", vbInformation, "zwj共享"   '完成
End Sub

Private Sub khd_SendProgress(Index As Integer, ByVal bytesSent As Long, ByVal bytesRemaining As Long)
Index = xhs
'List1.AddItem bytesSent
'List2.AddItem bytesRemaining
If PB1.Min = bytesRemaining Then '显示进度条

Else '显示进度条
PB1.Value = PB1.Value + bytesSent
End If '显示进度条

End Sub

Private Sub lw_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
wzgd.Enabled = False
End Sub

Private Sub sc_Click()
khd(xhs).SendData "删除" & wjmc
End Sub

Private Sub scwj_Timer() '上传数据
Open sclj For Binary As #4
Get #4, , scsj
khd(xhs).SendData scsj
zwjs = zwjs + 1
'List1.AddItem zwjs
Close #4
scwj.Enabled = False
End Sub

Private Sub scwjm_Timer()

 khd(xhs).SendData "文件名" & Dir(sclj)
scwjm.Enabled = False
End Sub

Private Sub ssfwq_Timer()
xhs = xhs + 1
Load khd(xhs)
khd(xhs).Connect ipsz(xhs), 1002
If xhs >= 255 Then
xhs = 0
ssfwq.Enabled = False
End If

End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
 If Button = "取消" Then '判断是否按了取消端
Beep
End '关闭
End If ''判断是否按了取消端

If Button = "下载" Then '按了下载端
If wjmc = "" Then
MsgBox "请选择文件！", vbInformation, "zwj共享"
Else
xz_Click
End If
End If '按了下载端

If Button = "刷新" Then '刷新
If khd(0).LocalIP = "127.0.0.1" Or lw.Caption <> "成功连接上服务器" Then
MsgBox "连不上服务器！！", vbInformation, "zwj共享"
Else
khd(xhs).SendData "刷新"
TV1.Nodes.Clear
End If
End If '刷新

If Button = "上传" Then '按了上传键
Dim wjlj As String
CD1.ShowOpen
sclj = CD1.FileName
 khd(xhs).SendData "文件名" & Dir(sclj)
'khd(xhs).SendData "上传" & FileLen(sclj)
ReDim scsj(FileLen(sclj))
PB1.Min = 0
PB1.Max = FileLen(sclj)
'List1.AddItem PB1.Max
'scwjm.Enabled = True
'scwj.Enabled = True



End If '按了上传键
End Sub
Private Sub tjip() '添加ip列表
Dim ipdz As String, dyd As String, ded As String, dsd As String, dxd As String
Dim dywz As Integer, dewz As Integer, dswz As Integer, dxwz As Integer
Dim i As Integer, ipnr As String
Dim iplj As String
iplj = App.Path & "\配置\ip.ini"
ipdz = khd(0).LocalIP
If ipdz = "127.0.0.1" Then '判断是否联网
lw.Caption = "断网络了。。。。。"
pds = False
wzgd.Enabled = True
Else '判断是否联网

ipnr = ipdz
dywz = InStr(ipnr, ".")
dyd = Left(ipnr, dywz - 1)
ipnr = Right(ipnr, Len(ipnr) - dywz)
'List2.AddItem ipnr
dewz = InStr(ipnr, ".")
ded = Left(ipnr, dewz - 1)
ipnr = Right(ipnr, Len(ipnr) - dewz)


dswz = InStr(ipnr, ".")
dsd = Left(ipnr, dswz - 1)
dxd = Right(ipnr, Len(ipnr) - dswz)

Kill (iplj)
Open iplj For Append As #1
Print #1, "127.0.0.1"
ipsz(1) = "127.0.0.1"
For i = 1 To 255
If ipdz = dyd & "." & ded & "." & dsd & "." & i Then '判断是否相同
Else '判断是否相同
Print #1, dyd & "." & ded & "." & dsd & "." & i
ipsz(i + 1) = dyd & "." & ded & "." & dsd & "." & i
End If '判断是否相同

Next i
Close #1
End If '判断是否联网
'MsgBox khd.LocalIP

End Sub

Private Sub TV1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
cmmm.Visible = False
End Sub

Private Sub TV1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
l2.Caption = x
l3.Caption = y
End Sub

Private Sub TV1_NodeClick(ByVal Node As ComctlLib.Node)
Dim cd As Menu
wjmc = Node
xmlb = TV1.SelectedItem.Index
Set cd = bj
PopupMenu bj
End Sub

Private Sub wzgd_Timer()
lw.Left = lw.Left - 100
If lw.Left < -1720 Then  '判断移动位置
lw.Left = 10560
End If  '判断移动位置

End Sub

Private Sub xz_Click()
CD1.FileName = wjmc
CD1.ShowSave
'MsgBox CD1.FileName
Open CD1.FileName For Binary As #3
khd(xhs).SendData "下载" & wjmc

End Sub
Private Sub sxsjj()

If Right(sjj, 3) = "txt" Or Right(sjj, 3) = "dat" Or Right(sjj, 3) = "doc" Then '判断文件扩展名
Set a = TV1.Nodes.Add(, , sjj, sjj, 3)
End If '判断文件扩建名

If Right(sjj, 3) = "jpg" Or Right(sjj, 3) = "bmp" Or Right(sjj, 3) = "ico" Or Right(sjj, 3) = "PNG" Or Right(sjj, 3) = "png" Or Right(sjj, 3) = "JPG" Then '判断文件扩展名
Set a = TV1.Nodes.Add(, , sjj, sjj, 2)
End If '判断文件扩建名

If Right(sjj, 3) = "rar" Or Right(sjj, 3) = "zip" Then '判断文件扩展名
Set a = TV1.Nodes.Add(, , sjj, sjj, 4)
End If '判断文件扩建名

If Right(sjj, 3) = "avi" Or Right(sjj, 3) = "flv" Or Right(sjj, 3) = "mp4" Or Right(sjj, 3) = "mvb" Then '判断文件扩展名
Set a = TV1.Nodes.Add(, , sjj, sjj, 1)
End If '判断文件扩建名

If Right(sjj, 3) = "exe" Then  '判断文件扩展名
Set a = TV1.Nodes.Add(, , sjj, sjj, 5)
End If '判断文件扩建名

If Right(sjj, 3) = "mp3" Or Right(sjj, 3) = "wma" Or Right(sjj, 3) = "MP3" Or Right(sjj, 3) = "WMA" Then '判断文件扩展名
Set a = TV1.Nodes.Add(, , sjj, sjj, 8)
End If '判断文件扩建名j


If Right(sjj, 3) = "ocx" Or Right(sjj, 3) = "OCX" Or Right(sjj, 3) = "dll" Or Right(sjj, 3) = "DLL" Then '判断文件扩展名
Set a = TV1.Nodes.Add(, , sjj, sjj, 9)
End If '判断文件扩建名
If Right(sjj, 3) = "lnk" Then  '判断文件扩展名
Set a = TV1.Nodes.Add(, , sjj, sjj, 6)
End If '判断文件扩建名

If Right(sjj, 3) = "dwg" Or Right(sjj, 3) = "DWG" Then  '判断文件扩展名
Set a = TV1.Nodes.Add(, , sjj, sjj, 7)
End If '判断文件扩建名


End Sub
Private Sub xgsj() '修改数据
Dim znr As String, i As Integer, zcd As Integer

Dim xhss As Integer, nr As String, n As Integer, nrsz(100) As String


znr = Text1.Text
zcd = Len(znr) '获取长度
For i = 1 To zcd '逐个获取数据
nr = Mid(znr, xhss + 1, 1) '赋值数据
xhss = xhss + 1
If nr = "." Then '判断数据
n = n + 1
sjj = Left(znr, xhss + 3)
Call sxsjj
'List1.AddItem Left(znr, xhss + 3)
znr = Right(znr, Len(znr) - xhss - 3)
zcd = Len(znr)
xhss = 0
End If '判断数据
Next i '逐个获取数据
End Sub '修改数据
