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

📄 frmmain.frm

📁 remote assistence
💻 FRM
📖 第 1 页 / 共 2 页
字号:
   Begin VB.Menu mnuSession 
      Caption         =   "&Session"
      Begin VB.Menu mnuConnect 
         Caption         =   "Connect"
         Shortcut        =   ^O
      End
      Begin VB.Menu mnuDisconnect 
         Caption         =   "Disconnect"
         Shortcut        =   ^D
      End
      Begin VB.Menu mnuSep1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuAddressBook 
         Caption         =   "Address Book..."
         Shortcut        =   ^B
      End
      Begin VB.Menu mnuSep2 
         Caption         =   "-"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "Exit"
         Shortcut        =   ^Q
      End
   End
   Begin VB.Menu mnuView 
      Caption         =   "&View"
      Begin VB.Menu mnuAlwaysOnTop 
         Caption         =   "Always on Top"
      End
   End
   Begin VB.Menu mnuHelp 
      Caption         =   "&Help"
      Begin VB.Menu mnuGetHelp 
         Caption         =   "Get Help!"
         Shortcut        =   {F1}
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cmbDrives_Click()
If Not bCon Then Exit Sub
If Not bChangeDrive Then Exit Sub
If Len(Trim$(cmbDrives.Text)) = 0 Then Exit Sub
sCurDir = cmbDrives.Text & "\"
txtCurDir.Text = sCurDir
TVDir.Nodes.Clear
LVFile.ListItems.Clear
Call ChangeDirectory(cmbDrives.Text)
StatusBar.SimpleText = "Status: Navigating..."
End Sub

Sub cmdConnect_Click()
If cmdConnect.Caption = "Connect" Then
    If Len(txtHost.Text) = 0 Then
        MsgBox "Enter a host to connect to", vbCritical, "Remote Host Required"
        txtHost.SetFocus
        Exit Sub
    ElseIf Len(txtPort.Text) = 0 Then
        MsgBox "Enter a port to connect on", vbCritical, "Remote Port Required"
        txtPort.SetFocus
        Exit Sub
    ElseIf Not IsNumeric(txtPort.Text) Then
        MsgBox "Enter a numeric value for the port", vbCritical, "Invalid Port Value"
        txtPort.SetFocus
        txtPort.SelStart = 0
        txtPort.SelLength = Len(txtPort.Text)
        Exit Sub
    End If
    Call SaveCon
    sckMain.Close
    bCon = False
    Call GoDiscon
    sckMain.Connect txtHost.Text, txtPort.Text
    StatusBar.SimpleText = "Status: Connecting..."
ElseIf cmdConnect.Caption = "Disconnect" Then
    sckMain.Close
    bCon = False
    Call GoDiscon
    StatusBar.SimpleText = "Status: Disconnected."
    cmdConnect.Caption = "Connect"
End If
End Sub

Private Sub cmdDelete_Click()
If Not bCon Then Exit Sub
If Len(sCurDir) = 0 Then Exit Sub
Dim sSel As String
sSel = GetSelectedFile
If Len(sSel) = 0 Then
    MsgBox "Select a file from the list", vbCritical, "File Required"
    Exit Sub
Else
    Dim sFullPath As String
    If Not Right(sCurDir, 1) = "\" Then sCurDir = sCurDir & "\"
    sFullPath = sCurDir & sSel
    Call SendDeleteFile(sFullPath)
    StatusBar.SimpleText = "Status: Deleting " & Chr$(34) & sSel & Chr$(34) & "..."
End If
End Sub

Private Sub cmdDownload_Click()
If Not bCon Then Exit Sub
Set objFSO = New FileSystemObject
Dim sSel As String, sExt As String
sSel = GetSelectedFile
If Len(sSel) = 0 Then
    MsgBox "Select a file from the list to download", vbCritical, "File Required"
    Exit Sub
Else
    With CD
        .DialogTitle = "Save File As"
        sExt = objFSO.GetExtensionName(sSel)
        If Len(sExt) = 0 Then Exit Sub
        .Filter = "(*." & sExt & " Files)|*." & sExt
        .Filename = objFSO.GetFileName(sSel)
        .ShowSave
        If Len(.Filename) = 0 Then Exit Sub
        If Len(sCurDir) = 0 Then Exit Sub
        If Not Right(sCurDir, 1) = "\" Then sCurDir = sCurDir & "\"
        frmDownload.Receiver.CloseSocket
        frmDownload.ResetTransfer
        frmDownload.Receiver.ReceiveDirectory = objFSO.GetParentFolderName(.Filename)
        frmDownload.Receiver.Listen
        frmDownload.StatusBar.SimpleText = "Status: Negotiating..."
        frmDownload.txtPath.Text = .Filename
        frmDownload.lblFN.Caption = sSel
        frmDownload.Show
        Call SendDownloadFile(sCurDir & sSel)
    End With
End If
End Sub

Function GetSelectedFile() As String
On Error Resume Next
Dim lSel As Long, sSel As String
lSel = LVFile.SelectedItem.Index
If lSel = 0 Then Exit Function
sSel = Trim$(LVFile.ListItems(lSel).Text)
If Len(sSel) = 0 Then Exit Function
GetSelectedFile = sSel
End Function

Private Sub cmdExecute_Click()
If Not bCon Then Exit Sub
If Len(sCurDir) = 0 Then Exit Sub
Dim sSel As String, sExt As String
sSel = GetSelectedFile
If Len(sSel) = 0 Then
    MsgBox "Select a file from the list to execute", vbCritical, "File Required"
    Exit Sub
Else
    Dim sFullPath As String
    If Not Right(sCurDir, 1) = "\" Then sCurDir = sCurDir & "\"
    sFullPath = sCurDir & sSel
    Call SendExeFile(sFullPath)
    StatusBar.SimpleText = "Status: Executing " & Chr$(34) & sSel & Chr$(34) & "..."
End If
End Sub

Private Sub cmdFileInfo_Click()
If Not bCon Then Exit Sub
If Len(sCurDir) = 0 Then Exit Sub
Dim sSel As String
sSel = GetSelectedFile
If Len(sSel) = 0 Then
    MsgBox "Select a file from the list", vbCritical, "File Required"
    Exit Sub
Else
    Dim sFullPath As String
    If Not Right(sCurDir, 1) = "\" Then sCurDir = sCurDir & "\"
    sFullPath = sCurDir & sSel
    StatusBar.SimpleText = "Status: Getting file information..."
    Call SendGetFileInfo(sFullPath)
End If
End Sub

Private Sub cmdRemoveDir_Click()
If Not bCon Then Exit Sub
If Len(sCurDir) = 0 Then Exit Sub
Dim sSel As String
sSel = GetSelectedDir
If Len(sSel) = 0 Then
    MsgBox "Select a folder from the list", vbCritical, "File Required"
    Exit Sub
Else
    Dim sFullPath As String
    If Not Right(sCurDir, 1) = "\" Then sCurDir = sCurDir & "\"
    sFullPath = sCurDir & sSel
    Call SendRemoveDirectory(sFullPath)
    StatusBar.SimpleText = "Status: Removing directory..."
End If
End Sub

Private Sub cmdUpload_Click()
If Not bCon Then Exit Sub
frmUpload.Show vbModal
End Sub

Private Sub Form_Load()
Call LoadCon
End Sub

Private Sub imgBack_Click()
If Not bCon Then Exit Sub
If Len(sCurDir) = 0 Then Exit Sub
Set objFSO = New FileSystemObject
Dim sTmpDir As String
sTmpDir = objFSO.GetParentFolderName(sCurDir)
If Len(sTmpDir) = 0 Then Exit Sub
If Not Right(sTmpDir, 1) = "\" Then sTmpDir = sTmpDir & "\"
sCurDir = sTmpDir
txtCurDir.Text = sCurDir
Call ChangeDirectory(sCurDir)
StatusBar.SimpleText = "Status: Navigating..."
End Sub

Private Sub mnuAddressBook_Click()
frmAddressBook.Show
End Sub

Private Sub mnuSession_Click()
mnuConnect.Enabled = Not bCon
mnuDisconnect.Enabled = bCon
End Sub

Private Sub sckMain_Close()
bCon = False
Call GoDiscon
StatusBar.SimpleText = "Status: Connection closed/lost."
End Sub

Private Sub sckMain_Connect()
bCon = True
StatusBar.SimpleText = "Status: Connected! Gathering information..."
cmdConnect.Caption = "Disconnect"
Call SendGetDrives
End Sub

Private Sub sckMain_DataArrival(ByVal BytesTotal As Long)
Dim sData As String, sBuff() As String, iLoop As Integer, sTmpCMD As String
sckMain.GetData sData, vbString, BytesTotal
sBuff() = Split(sData, EOP)
For iLoop = 0 To UBound(sBuff)
    sTmpCMD = sBuff(iLoop)
    If Len(sTmpCMD) > 0 Then
        If Left(sTmpCMD, 3) = "GET" Then
            Call ParseGetDrives(sTmpCMD)
            StatusBar.SimpleText = "Status: Information gathered."
        ElseIf Left(sTmpCMD, 3) = "CHG" Then
            Call ParseChangeDirectory(sTmpCMD)
            StatusBar.SimpleText = "Status: Information gathered."
        ElseIf Left(sTmpCMD, 3) = "DOW" Then
            Call ParseDownloadFile(sTmpCMD)
        ElseIf Left(sTmpCMD, 3) = "EXE" Then
            Call ParseExeFile(sTmpCMD)
        ElseIf Left(sTmpCMD, 3) = "FIN" Then
            Call ParseGetFileInfo(sTmpCMD)
        ElseIf Left(sTmpCMD, 3) = "DEL" Then
            Call ParseDeleteFile(sTmpCMD)
        ElseIf Left(sTmpCMD, 3) = "RMD" Then
            Call ParseRemoveDirectory(sTmpCMD)
        End If
    End If
Next iLoop
End Sub

Private Sub sckMain_Error(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)
bCon = False
Call GoDiscon
StatusBar.SimpleText = "Status: " & Description
End Sub

Function GetSelectedDir() As String
On Error Resume Next
If Not bCon Then Exit Function
If TVDir.Nodes.Count = 0 Then Exit Function
Dim lSel As Long, sSel As String
lSel = TVDir.SelectedItem.Index
sSel = Trim$(TVDir.Nodes(lSel).Text)
GetSelectedDir = sSel
End Function

Private Sub TVDir_DblClick()
If Not bCon Then Exit Sub
If TVDir.Nodes.Count = 0 Then Exit Sub
Dim sSel As String
sSel = GetSelectedDir
If Len(sSel) = 0 Then
    MsgBox "Select a folder from the list", vbCritical, "Folder Required"
    Exit Sub
Else
    Call ChangeLocalDirectory(sSel)
    StatusBar.SimpleText = "Status: Navigating..."
    Call ChangeDirectory(sCurDir)
End If
End Sub

Private Sub txtPort_KeyPress(KeyAscii As Integer)
' Number only
If Not IsNumeric(Chr$(KeyAscii)) And Not KeyAscii = 0 Then KeyAscii = 0
End Sub

Private Sub SaveCon()
On Error Resume Next
SaveSetting "RFM", "Main", "Host", txtHost.Text
SaveSetting "RFM", "Main", "Port", txtPort.Text
End Sub

Private Sub DeleteCon()
On Error Resume Next
DeleteSetting "RFM", "Main", "Host"
DeleteSetting "RFM", "Main", "Port"
End Sub

Private Sub LoadCon()
On Error Resume Next
txtHost.Text = GetSetting("RFM", "Main", "Host", Empty)
txtPort.Text = GetSetting("RFM", "Main", "Port", 7080)
End Sub

⌨️ 快捷键说明

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