A simple "Process Manager"

If you have completed an application and wish to share the complete source/project files with everyone then please post it in here. Source-code files only, no tutorials.
4 posts Page 1 of 1
Contributors
User avatar
Esky
VIP - Donator
VIP - Donator
Posts: 86
Joined: Tue Dec 22, 2009 11:36 am

A simple "Process Manager"
Esky
Hi everyone i was bored last night and i wanted to know how to do stuff with system process etc.. i learnt so i may as well share my little knowledge with you... its not that handy tho some of you might find some of the code helpful :P enjoy

The program detects another instance of itself, it can search to see if a process by a name is running, see information about a selected process and finely kill a process.

Image
Code: Select all
Public Class Main

    Public Sub New()
        InitializeComponent()
        UpdateProcessList()
    End Sub

    Private Sub UpdateProcessList()
        Try
            ProcessList.Items.Clear()
            Info.Text = ""

            Dim p As System.Diagnostics.Process

            For Each p In System.Diagnostics.Process.GetProcesses()
                ProcessList.Items.Add(p.ProcessName)
            Next

            ProcessList.Sort()

            tslProcessCount.Text = "Processes running: " & ProcessList.Items.Count.ToString()

        Catch ex As Exception
            MsgBox("An error occured while trying to retrieve process list.")
        End Try

    End Sub

    Private Sub btnUpdateProcessList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateProcessList.Click
        UpdateProcessList()
    End Sub

    Private Sub btnKill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKill.Click
        Try
            If SelectedProcess.Text = Nothing Then
                MsgBox("Click on a process name to select it.")
            Else

                Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName(SelectedProcess.Text)

                For Each p As Process In pProcess
                    p.Kill()
                Next
                UpdateProcessList()
            End If
        Catch ex As Exception
            MsgBox("An error occured while trying to kill process.")
        End Try
    End Sub

    Private Sub ProcessList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProcessList.SelectedIndexChanged
        Dim PROCESSNAME As String = ProcessList.FocusedItem.ToString
        PROCESSNAME = Replace(PROCESSNAME, "ListViewItem: {", "")
        PROCESSNAME = Replace(PROCESSNAME, "}", "")
        SelectedProcess.Text = PROCESSNAME

        Try
            Dim p As System.Diagnostics.Process
            For Each p In System.Diagnostics.Process.GetProcessesByName(PROCESSNAME)
                Info.Text = "ProcessName: " & p.ProcessName & vbNewLine
                Info.Text = Info.Text & "ProcessID: " & p.Id & vbNewLine
                Info.Text = Info.Text & "Responding: " & p.Responding & vbNewLine
                Info.Text = Info.Text & "BasePriority:  " & p.BasePriority & vbNewLine
                Info.Text = Info.Text & "EnableRaisingEvents:  " & p.EnableRaisingEvents & vbNewLine
                Info.Text = Info.Text & "HandleCount:  " & p.HandleCount & vbNewLine
                Info.Text = Info.Text & "MainWindowTitle:  " & p.MainWindowTitle & vbNewLine
                Info.Text = Info.Text & "NonpagedSystemMemorySize:  " & p.NonpagedSystemMemorySize & vbNewLine
                Info.Text = Info.Text & "PagedMemorySize:  " & p.PagedMemorySize & vbNewLine
                Info.Text = Info.Text & "PagedSystemMemorySize:  " & p.PagedSystemMemorySize & vbNewLine
                Info.Text = Info.Text & "PeakPagedMemorySize:  " & p.PeakPagedMemorySize & vbNewLine
                Info.Text = Info.Text & "PeakVirtualMemorySize:  " & p.PeakVirtualMemorySize & vbNewLine
                Info.Text = Info.Text & "PeakWorkingSet:  " & p.PeakWorkingSet & vbNewLine
                Info.Text = Info.Text & "PrivateMemorySize:  " & p.PrivateMemorySize & vbNewLine
                Info.Text = Info.Text & "SessionId:  " & p.SessionId & vbNewLine
                Info.Text = Info.Text & "VirtualMemorySize:  " & p.VirtualMemorySize & vbNewLine
                Info.Text = Info.Text & "WorkingSet:  " & p.WorkingSet
            Next
        Catch ex As Exception
            Info.Text = "An error occured while tyring to retrive infomation."
        End Try

    End Sub

    Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
            MsgBox("Another instance of the program is currently running!")
        Else

        End If
    End Sub

    Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
        If System.Diagnostics.Process.GetProcessesByName(SelectedProcess.Text).Count > 0 Then
            MsgBox("A process by the name of " & SelectedProcess.Text & " is currently running!")
        ElseIf SelectedProcess.Text = Nothing Then
            MsgBox("No process name found!")
        Else
            MsgBox("No process by the name of " & SelectedProcess.Text & " is currently running")
        End If
    End Sub
End Class
You do not have the required permissions to view the files attached to this post.
Current Project: Server Browser - Beta & Text based MMORPG
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4390
Joined: Tue Aug 04, 2009 1:47 am

Re: A simple "Process Manager"
CodenStuff
Hello,

This is excellent Esky, good work keep it up cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Hi Esky
Great stuff clapper; cooll;


Chris
Image
User avatar
rocky4126
VIP - Donator
VIP - Donator
Posts: 258
Joined: Mon Nov 16, 2009 7:39 pm

Re: A simple "Process Manager"
rocky4126
hi esky, best yet! I been lookin for a process manager source like what they did in cheat engine 5.x clapper; wahooo; clapper; clapper; cooll; cooll; cooll; cooll; cooll;
Image
4 posts Page 1 of 1
Return to “Source-Code”