Click here to Skip to main content
11,637,662 members (77,411 online)
Click here to Skip to main content
Articles » Languages » VB.NET » Utilities » Downloads
Add your own
alternative version

A Process viewer with alert notification

, 20 May 2008 CPOL 37.2K 2.1K 52
Simple process viewer that is capable of setting alerts for process events.
processviewer_src.zip
ProcessViewer
ProcessViewer.suo
ProcessViewer
bin
Debug
ProcessInfo.dll
ProcessInfo.pdb
ProcessViewer.exe
ProcessViewer.pdb
ProcessViewer.vshost.exe
Release
App.ico
ProcessInfo.dll
ProcessInfo.pdb
ProcessViewer.exe
ProcessViewer.pdb
My Project
Application.myapp
Settings.settings
obj
Debug
ProcessViewer.ProcessExp.resources
ProcessViewer.ProcessExplorer.resources
ProcessViewer.Resources.resources
TempPE
My Project.Resources.Designer.vb.dll
ProcessViewer.vbproj.GenerateResource.Cache
ResolveAssemblyReference.cache
ProcessViewer.pdb
ProcessViewer.exe
Release
ProcessViewer.exe
ProcessViewer.pdb
ProcessViewer.ProcessExp.resources
ProcessViewer.Resources.resources
ProcessViewer.vbproj.GenerateResource.Cache
ResolveAssemblyReference.cache
TempPE
My Project.Resources.Designer.vb.dll
procexpSmall.ico
procexpLarge.ico
ProcessInfo
ProcessInfo.suo
ProcessInfo
bin
Debug
ProcessInfo.dll
ProcessInfo.pdb
Release
ProcessInfo.dll
ProcessInfo.pdb
obj
Debug
ProcessInfo.dll
TempPE
ProcessInfo.pdb
Release
ProcessInfo.dll
ProcessInfo.pdb
TempPE
Properties
'***********************************************************************************************
'* File Name	: ProcessExp.vb
'* Description	: This class is main user interface elements, which provide all user interaction
'* 
'* Author		: Ashutosh Fouzdar, Software Engineer Ness Technologies India Ltd.
'* Date			: 08-June-2007
'* ***********************************************************************************************/
 
Imports Win32Process
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.ComponentModel

Public Class ProcessExp
    Private pr(10) As ProcessInfo
    Private Shared prctr As Byte = 0
    Private tbl As New DataTable()
    
    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        If Me.txtProcessName.Text <> "" Then
            If prctr > 9 Or prctr < 0 Then
                MessageBox.Show("Only 10 applications can be monitored", "Limit Exceed", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Exit Sub
            End If
            pr(prctr) = New ProcessInfo(Me.txtProcessName.Text, Me.txtMachineName.Text)
            AddHandler pr(prctr).Started, New ProcessInfo.StartedEventHandler(AddressOf Process_Started)
            AddHandler pr(prctr).Terminated, New ProcessInfo.TerminatedEventHandler(AddressOf Process_Stopped)
            Me.lstMonitor.Items.Add(Me.txtProcessName.Text)
            prctr += 1
        End If
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub
    
    Private Sub ProcessExp_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Dim ctr As Byte = 0
        For ctr = 0 To 9
            If Not (pr(ctr) Is Nothing) Then
                pr(ctr).Dispose()
            End If
        Next
        Application.Exit()
    End Sub
    
    Private Sub ProcessExp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            tbl = ProcessInfo.LoadProcess()
            Me.DataGridView1.DataSource = tbl
            Me.DataGridView1.Columns(0).Width = 100
            Me.DataGridView1.Columns(1).Width = 200
            Me.DataGridView1.Columns(2).Width = 200
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Process Loading:", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try

    End Sub
    Private Sub Process_Started(ByVal sender As System.Object, ByVal e As System.EventArgs)
    	Dim tmpProcess as ProcessInfo=CType(sender,ProcessInfo)
        Me.Systray.BalloonTipIcon=ToolTipIcon.Info
        Me.Systray.BalloonTipText="Process " + tmpProcess.AppName + " Started"
        Me.Systray.BalloonTipTitle="Alert"
        Me.Systray.ShowBalloonTip(5000)
    End Sub
    
    Private Sub Process_Stopped(ByVal sender As System.Object, ByVal e As System.EventArgs)
    	Dim tmpProcess as ProcessInfo=CType(sender,ProcessInfo)
        Me.Systray.BalloonTipIcon=ToolTipIcon.Info
        Me.Systray.BalloonTipText="Process " + tmpProcess.AppName + " Stopped"
        Me.Systray.BalloonTipTitle="Alert"
        Me.Systray.ShowBalloonTip(5000)
    End Sub
  
	Private Sub DataGridView1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
        If Me.DataGridView1.SelectedRows.Count > 0  Then
        	Me.txtProcessName.Text = Me.DataGridView1.SelectedRows(0).Cells(1).Value.ToString() + ".exe"
        End If
    End Sub
    
    Sub TmrTickTick(ByVal sender As Object, ByVal e As EventArgs)
    	 Try
            tbl = ProcessInfo.LoadProcess()
            Me.DataGridView1.DataSource = tbl
'            Me.DataGridView1.Columns(0).Width = 100
'            Me.DataGridView1.Columns(1).Width = 200
'            Me.DataGridView1.Columns(2).Width = 200
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Process Loading:", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ashutosh Phoujdar
Architect Infosys Technologies Ltd.
India India
An Software Architect having work experience of 8+ years in Architecture, Design and Development of Enterprise class application for Analytic s and Business Intelligence. Having hands-on experience primarily in Microsoft Technology Stack including(but not limited to) .NET, SQL Server, SharePoint Server, Biztalk, Withal know to program in Java, Perl and Shell. Currently working as Product Technical Architect in Infosys Technologies Ltd. Products R&D division. He has worked on development of best in class Supply Chain Optimization System and Spend Classification Software for optimizing indirect spend. An avid programmer by heart and passionate for solving any challenging and complex business problems. He is advocate of Open source and love to share solutions with open source communities like
1.Stack Overflow
2. nHibernate
.

Award's :
Prize winner in Competition "Best article of May 2008"

Articles :
Click to see my CodeProject Articles

Open Source Contributions:
Click to see my Open Source Project

Blog :
Share a solution | Explore the .NET world

Link'd :
LinkedIn Profile

His Favorite(s) :
nHibernate - The best ORM.
nHibernate Contributed Tools

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150728.1 | Last Updated 21 May 2008
Article Copyright 2008 by Ashutosh Phoujdar
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid