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

📄 form1.frm

📁 remote process view
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomctl.ocx"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4980
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9315
   LinkTopic       =   "Form1"
   ScaleHeight     =   4980
   ScaleWidth      =   9315
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton cmdKill 
      Caption         =   "Kill"
      Enabled         =   0   'False
      Height          =   420
      Left            =   7440
      TabIndex        =   3
      Top             =   2040
      Width           =   975
   End
   Begin VB.ComboBox cobCompute 
      Height          =   300
      Left            =   7200
      TabIndex        =   1
      Text            =   "pc25"
      Top             =   600
      Width           =   1695
   End
   Begin MSComctlLib.ListView lstView 
      Height          =   4095
      Left            =   480
      TabIndex        =   0
      Top             =   480
      Width           =   6375
      _ExtentX        =   11245
      _ExtentY        =   7223
      View            =   3
      Sorted          =   -1  'True
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   0
   End
   Begin VB.CommandButton cmdGetPID 
      Caption         =   "Connect"
      Height          =   420
      Left            =   7440
      TabIndex        =   2
      Top             =   1320
      Width           =   975
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim fso As FileSystemObject, txtStream As TextStream


Private Sub cmdGetPID_Click()
    On Error Resume Next
    Dim strFileName, strBat, strContent, strMain As String
    Dim intContent, intPos, intIndex As Integer
    Dim xSubItem As ListItem
    Dim ModifiedTime As Date
    strFileName = App.Path & "\temp.txt"
    strBat = App.Path & "\temp.bat"
    Set fso = New FileSystemObject
    Set txtStream = fso.CreateTextFile(strBat, True)
    
    If Not IsNull(cobCompute) Or cobCompute <> "" Then
        txtStream.WriteLine "tasklist /s \\" & cobCompute & " /fo ""list"" >" & strFileName
        DoEvents
        txtStream.Close
        If Shell("temp.bat") <= 0 Then
            MsgBox "调用失败"
        End If
        Do
            ModifiedTime = fso.GetFile(strFileName).DateLastModified
        Loop Until ModifiedTime = Now()
        'txtStream.Close
        Set txtStream = Nothing
        Set txtStream = fso.OpenTextFile(strFileName, ForReading)
        lstView.ListItems.Clear
        Do While txtStream.AtEndOfStream <> True
            strContent = Trim(txtStream.ReadLine) '读取一行的内容
            intContent = Len(strContent)
            intPos = InStr(1, strContent, ":", vbTextCompare) '判断一行是不是有:号
            If intPos > 1 Then
                strMain = Trim(Right(strContent, (intContent - intPos))) '得到:号后面的字符
                Select Case Trim(Left(strContent, (intPos - 1))) '得到:号前面的字符
                    Case "图像名"
                        intIndex = intIndex + 1
                        Set xSubItem = lstView.ListItems.Add(, , strMain)
                    Case "PID"
                       xSubItem.ListSubItems.Add , , strMain
                    Case "内存使用"
                        xSubItem.ListSubItems.Add , , strMain
                End Select
            End If
            
        Loop
    End If
    txtStream.Close
    Set fso = Nothing
    Set txtStream = Nothing
    Kill strBat '删除文件
   ' Kill strFileName
    cmdKill.Enabled = True
Exit Sub

ErrMsg:
    MsgBox Err.Description, vbCritical, "错误"
End Sub



Private Sub cmdKill_Click()
    MsgBox lstView.SelectedItem.ListSubItems(1)
    
End Sub

Private Sub Form_Load()
    Dim colWidth
    colWidth = lstView.Width / 3 - 130
    With lstView.ColumnHeaders
        .Add , "Image", "Image Name", colWidth
        .Add , "PID", "Progress ID", colWidth, lvwColumnCenter
        .Add , "Momory", "Memory Size", colWidth, lvwColumnCenter
    End With
    
End Sub

⌨️ 快捷键说明

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