TechSapphire Thursday, 2024-11-07, 10:38 AM
Site menu
Login form
News
Play Games
  • Deep Freeze
  • Ice Slide
  • Gyroball
  • Fat Fish
  • Bush Royal Rampage
  • Task manager using .Net Or Task manager using VB.net Or Control processes using .Net

    With this code you could inherit task manager control in your windows form using VB.net. If you find difficulty in using this code, you could download form from here and attach it to your project.



    Solution code:

    Imports System
    Imports System.Diagnostics
    Public Class taskmanage
        Inherits System.Windows.Forms.Form
        Private Sub taskmanage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            txtMachine.Text = System.Environment.MachineName.ToString
            Call FillList(txtMachine.Text)
        End Sub
        Sub FillList(ByVal MachineName As String)
            Dim Prc() As Process
            Dim i As Integer
            Dim lvwP As ListViewItem
            Try
                lvwProcesses.Items.Clear()
                Prc = Process.GetProcesses(MachineName)

                For i = 0 To UBound(Prc)
                    lvwP = lvwProcesses.Items.Add(Prc(i).ProcessName.ToUpper)

                    If MachineName <> System.Environment.MachineName Then
                        lvwP.SubItems.Add("Unavailable...")
                        lvwP.SubItems.Add("Unavailable...")
                        lvwP.SubItems.Add(Prc(i).Id)
                    Else
                        lvwP.SubItems.Add(Prc(i).MainWindowTitle)
                        lvwP.SubItems.Add(Prc(i).Responding)
                        lvwP.SubItems.Add(Prc(i).Id)
                    End If

                Next
            Catch
                lvwProcesses.Items.Add("Error enumerating items...")
            End Try
        End Sub

        Private Sub cmdEndProc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEndProc.Click
            Dim Prc As Process

            If txtMachine.Text = System.Environment.MachineName.ToString Then
                Try
                    Prc = Process.GetProcessById(lvwProcesses.SelectedItems(0).SubItems(3).Text)
                    Prc.Kill()
                    lvwProcesses.Items.Remove(lvwProcesses.SelectedItems.Item(0))
                Catch
                    MessageBox.Show("Could not close process, " & Err.Description, "Error:", MessageBoxButtons.OK, MessageBoxIcon.Stop)
                End Try
            Else
                MessageBox.Show("You cannot close processes on a remote machine, only view them!", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End If
        End Sub

        Private Sub cmdRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRefresh.Click
            txtMachine.Text = txtMachine.Text.ToUpper
            Call FillList(txtMachine.Text)
        End Sub

        Private Sub tpgProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tpgProcess.Click

        End Sub
    End Class

    Download form, Click Here.
    Categories
    Programming [27]
    Tips for programming
    Security [2]
    Security Tips
    Google [1]
    Use google faster then ever you use
    Project [14]
    HTML [2]
    Electronics [0]
    Data Structure [0]
    Database [16]
    SQL SERVER
    SSRS [1]
    Sql Server Reporting Services
    Copyright MyCorp © 2024