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

📄 form1.frm

📁 vb发送文件,检查邮件,串口操作,查看文件等关于socket的源代码!
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmNWCheck 
   Caption         =   "网上邻居/共享资源设定"
   ClientHeight    =   6195
   ClientLeft      =   3225
   ClientTop       =   2040
   ClientWidth     =   7140
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   6195
   ScaleWidth      =   7140
   Begin MSComctlLib.ImageList imlNWImages 
      Left            =   0
      Top             =   5280
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   13
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":08CA
            Key             =   "directory"
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0C1C
            Key             =   "root"
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":0F6E
            Key             =   "group"
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":12C0
            Key             =   "ndscontainer"
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":1612
            Key             =   "network"
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":1964
            Key             =   "server"
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":1CB6
            Key             =   "tree"
         EndProperty
         BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":2008
            Key             =   "domain"
         EndProperty
         BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":235A
            Key             =   "share"
         EndProperty
         BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":26AC
            Key             =   "adminshare"
         EndProperty
         BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":29FE
            Key             =   "printer"
         EndProperty
         BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":2B10
            Key             =   "folder"
         EndProperty
         BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "Form1.frx":54A4
            Key             =   "file"
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.TreeView tvwNetwork 
      Height          =   5175
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   7080
      _ExtentX        =   12488
      _ExtentY        =   9128
      _Version        =   393217
      HideSelection   =   0   'False
      Indentation     =   176
      LabelEdit       =   1
      Style           =   7
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.Menu mnuFile 
      Caption         =   "文件(&F)"
      Begin VB.Menu mnuFileMapDisk 
         Caption         =   "创建映射(&M)..."
      End
      Begin VB.Menu mnuFileSetShareFolder 
         Caption         =   "创建共享文件夹(&S)..."
      End
   End
End
Attribute VB_Name = "frmNWCheck"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Const RESOURCETYPE_ANY = &H0
Private Const RESOURCETYPE_DISK = &H1
Private Const RESOURCETYPE_PRINT = &H2
Private Const RESOURCETYPE_UNKNOWN = &HFFFF

Private Declare Function WNetConnectionDialog Lib "mpr.dll" (ByVal hwnd As Long, ByVal dwType As Long) As Long

Private NetRoot As NetResource


Private Sub NodeExpand(Node As MSComctlLib.Node)

    Dim FSO As Scripting.FileSystemObject
    Dim NWFolder As Scripting.Folder
    Dim FilX As Scripting.File, DirX As Scripting.Folder
    Dim tNod As Node, isFSFolder As Boolean
    
    tvwNetwork.Nodes.Remove Node.Key + "_FAKE"
    
    If Node.SelectedImage = "share" Then
        On Error Resume Next
        Set FSO = New FileSystemObject
        Set NWFolder = FSO.GetFolder(Node.Key)
        If Err <> 0 Then isFSFolder = False Else isFSFolder = True
        On Error GoTo 0
    End If
    
    If Node.SelectedImage = "folder" Or (Node.SelectedImage = "share" And isFSFolder = True) Then
        Set FSO = New Scripting.FileSystemObject
        Set NWFolder = FSO.GetFolder(Node.Key)
        For Each FilX In NWFolder.Files
            tvwNetwork.Nodes.Add Node.Key, tvwChild, Node.Key + "\" + FilX.Name, FilX.Name, "file", "file"
        Next
        ' 枚句文件夹
        For Each DirX In NWFolder.SubFolders
            Set tNod = tvwNetwork.Nodes.Add(Node.Key, tvwChild, Node.Key + "\" + DirX.Name, DirX.Name, "folder", "folder")
            tvwNetwork.Nodes.Add tNod.Key, tvwChild, tNod.Key + "_FAKE", "FAKE", "folder", "folder"
            tNod.Tag = "N"
        Next
        Node.Tag = "Y"
    Else
        Dim pS As String, kPath() As String, nX As NetResource, I As Integer, tX As NetResource
        Set tNod = Node
        Do While Not tNod.Parent Is Nothing
            pS = tNod.Key + "|" + pS
            Set tNod = tNod.Parent
        Loop
        kPath = Split(pS, "|")
        Set nX = NetRoot
        For I = 0 To UBound(kPath) - 1
            Set nX = nX.Children(kPath(I))
        Next
        For Each tX In nX.Children
            Set tNod = tvwNetwork.Nodes.Add(nX.RemoteName, tvwChild, tX.RemoteName, tX.ShortName, LCase(tX.ResourceTypeName), LCase(tX.ResourceTypeName))
            tNod.Tag = "N"
            If tX.ResourceType <> Printer Then tvwNetwork.Nodes.Add tX.RemoteName, tvwChild, tX.RemoteName + "_FAKE", "FAKE", "server", "server"
        Next
        tvwNetwork.Refresh
        Node.Tag = "Y"          ' 设置Y,表示本节点已经展开
    End If

End Sub


Private Sub Form_Load()
    Dim nX As NetResource, nodX As Node
    
    Me.Top = (Screen.Height - Me.Height) / 2
    Me.Left = (Screen.Width - Me.Width) / 2

    
    tvwNetwork.ImageList = imlNWImages
    Set NetRoot = New NetResource
    Set nodX = tvwNetwork.Nodes.Add(, , "_ROOT", "网上邻居", "root", "root")
    nodX.Tag = "Y"
    For Each nX In NetRoot.Children
        Set nodX = tvwNetwork.Nodes.Add("_ROOT", tvwChild, nX.RemoteName, nX.ShortName, LCase(nX.ResourceTypeName), LCase(nX.ResourceTypeName))
        nodX.Tag = "N"  '
        tvwNetwork.Nodes.Add nodX.Key, tvwChild, nodX.Key + "_FAKE", "FAKE", "server", "server"
        nodX.EnsureVisible
    Next
End Sub

Private Sub Form_Resize()
    tvwNetwork.Width = Me.ScaleWidth
    tvwNetwork.Height = Me.ScaleHeight
End Sub

Private Sub mnuFileMapDisk_Click()

    Call WNetConnectionDialog(Me.hwnd, RESOURCETYPE_DISK)

End Sub

Private Sub mnuFileSetShareFolder_Click()
    Load FrmNewShareFolder
    FrmNewShareFolder.Show
End Sub

Private Sub tvwNetwork_Expand(ByVal Node As MSComctlLib.Node)
    If Node.Tag = "N" Then
        NodeExpand Node
    End If
End Sub

Private Sub tvwNetwork_Mouseup(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 2 Then        ' 鼠标右键快捷菜单
        PopupMenu mnuFile
    End If
End Sub

⌨️ 快捷键说明

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