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

📄 frmservices.frm

📁 全面网络扫描器VB源代码 很实用
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmservices 
   BackColor       =   &H00000000&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Services"
   ClientHeight    =   4920
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   7695
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   4920
   ScaleWidth      =   7695
   Begin VB.Timer Timer2 
      Interval        =   100
      Left            =   5520
      Top             =   120
   End
   Begin VB.CommandButton Start 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Start"
      Height          =   375
      Left            =   6360
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   840
      Width           =   1215
   End
   Begin VB.CommandButton Pause 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Pause"
      Height          =   375
      Left            =   6360
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   1800
      Width           =   1215
   End
   Begin VB.CommandButton Stop 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Stop"
      Height          =   375
      Left            =   6360
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   1320
      Width           =   1215
   End
   Begin VB.CommandButton Exit 
      Caption         =   "Exit"
      Height          =   495
      Left            =   3240
      TabIndex        =   2
      Top             =   8640
      Width           =   1215
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   250
      Left            =   5040
      Top             =   120
   End
   Begin VB.TextBox Server 
      Height          =   285
      Left            =   0
      TabIndex        =   0
      Top             =   240
      Width           =   3375
   End
   Begin VB.CommandButton Connect 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Connect"
      Height          =   285
      Left            =   3600
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   240
      Width           =   1215
   End
   Begin MSComctlLib.ListView ListView1 
      Height          =   3975
      Left            =   0
      TabIndex        =   6
      Top             =   840
      Width           =   6255
      _ExtentX        =   11033
      _ExtentY        =   7011
      View            =   3
      LabelEdit       =   1
      LabelWrap       =   0   'False
      HideSelection   =   -1  'True
      _Version        =   393217
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   3
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "Service Name"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "Service Description"
         Object.Width           =   5468
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "Service State"
         Object.Width           =   2293
      EndProperty
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      BackColor       =   &H00FFFFFF&
      Height          =   255
      Left            =   0
      TabIndex        =   8
      Top             =   600
      Width           =   6135
   End
   Begin VB.Label Label1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Server"
      Height          =   255
      Left            =   0
      TabIndex        =   7
      Top             =   0
      Width           =   975
   End
End
Attribute VB_Name = "frmservices"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' by nima bagheri form  THECRACKERS_GROUP@yahoo.ca
'TEL 098-0151-2210510



Public Locator As SWbemLocator
Public services As SWbemServices
Public TimerCount
Public item As ListItem

Dim WithEvents eventSink As SWbemSink
Attribute eventSink.VB_VarHelpID = -1
    
Public Sub InitialiseView()
    ListView1.ListItems.Clear
End Sub

Private Sub Server_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
 Call Connect_Click
 DoEvents
 End If

End Sub

Private Sub Timer1_Timer()

TimerCount = TimerCount + 1
If TimerCount > 10 Then
    item.Bold = False
    Timer1.Enabled = False
    TimerCount = 0
Else
    item.Bold = Not item.Bold
End If

End Sub

Private Sub eventSink_OnObjectReady(ByVal Object As WbemScripting.ISWbemObject, ByVal AsyncContext As WbemScripting.ISWbemNamedValueSet)

Dim ServiceName
Dim ServiceStatus

ServiceName = Object.TargetInstance.Name
ServiceStatus = Object.TargetInstance.State
Set item = ListView1.FindItem(ServiceName)
item.SubItems(2) = ServiceStatus
item.Bold = True
Timer1.Enabled = True
TimerCount = 0

End Sub

Public Sub LoadView()

    Dim Enumerator As SWbemObjectSet
    Dim Object As SWbemObject
    Dim item As ListItem
    
    On Error GoTo err:
        
    SavePointer = form1.MousePointer
    form1.MousePointer = vbHourglass
    form1.Enabled = False
    ListView1.ListItems.Clear
    
    eventSink.Cancel
    
    Set services = Locator.ConnectServer(Server.Text)
    services.ExecNotificationQueryAsync eventSink, "Select * from __InstanceModificationEvent Within 2.0 Where TargetInstance Isa 'Win32_Service'"
    Set Enumerator = services.ExecQuery("Select * From Win32_Service")
    
    For Each Object In Enumerator
    
        Set item = ListView1.ListItems.Add(, Object.Name, Object.Name)
        If Object.Description <> "" Then item.SubItems(1) = Object.Description
        If Object.State <> "" Then item.SubItems(2) = Object.State
        
    Next
    
    form1.Enabled = True
    form1.MousePointer = SavePointer
    'MDIFrmmain.StatusBar1.Panels(1).Text = "Status:"
   Exit Sub
err:
    MsgBox err.Description, , "Tip"
    
End Sub

Private Sub Form_Load()

    Set Locator = New SWbemLocator
    Set eventSink = New SWbemSink
    
    InitialiseView

End Sub

Private Sub Connect_Click()
    
    LoadView

End Sub

Private Sub Exit_Click()

    End
    
End Sub

Private Sub Pause_Click()
'MDIFrmmain.StatusBar1.Panels(1).Text = "Status: Working..."
    Dim ServiceObject As SWbemObject
    Dim ServiceName
    
    On Error Resume Next
    ServiceName = ListView1.SelectedItem.Text
    If err.Number = 0 Then
    
        Set ServiceObject = services.Get("Win32_Service='" & ServiceName & "'")
        
        ' Note how the CIM method "PauseService" of Win32_Service
        ' is executed as if it were an automation method of SWbemObject
        ServiceObject.PauseService
    End If
'MDIFrmmain.StatusBar1.Panels(1).Text = "Status:"
End Sub

Private Sub Start_Click()
'MDIFrmmain.StatusBar1.Panels(1).Text = "Status: Working..."
    Dim ServiceObject As SWbemObject
    Dim ServiceName
    
    On Error Resume Next
    ServiceName = ListView1.SelectedItem.Text
    If err.Number = 0 Then
    
        ' Note how the CIM method "StartService" of Win32_Service
        ' is executed as if it were an automation method of SWbemObject
        Set ServiceObject = services.Get("Win32_Service='" & ServiceName & "'")
        ServiceObject.StartService
    End If
'MDIFrmmain.StatusBar1.Panels(1).Text = "Status:"
End Sub

Private Sub Stop_Click()
'MDIFrmmain.StatusBar1.Panels(1).Text = "Status: Working..."
    Dim ServiceObject As SWbemObject
    Dim ServiceName
    
    On Error Resume Next
    ServiceName = ListView1.SelectedItem.Text
    If err.Number = 0 Then
    
        ' Note how the CIM method "StopService" of Win32_Service
        ' is executed as if it were an automation method of SWbemObject
        Set ServiceObject = services.Get("Win32_Service='" & ServiceName & "'")
        ServiceObject.StopService
    End If
'MDIFrmmain.StatusBar1.Panels(1).Text = "Status:"
End Sub


Private Sub Timer2_Timer()
 Label2.Caption = "Total Services: " & ListView1.ListItems.Count
End Sub

⌨️ 快捷键说明

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