CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2005
    Posts
    10

    [RESOLVED] How to monitory drive activity in vb 2008

    I'm looking for a way to monitor drive activity using Visual Basic 2008. I want to create a small utility to simulate an LED in the system tray for drive read/write activity. I've found several such utilities that do this, but they all lack one thing or another, or they are over bloated with stuff I don't want or need, etc. I want to write my own so it will be like I want it. To get started, I need to know how to monitor drive activity. Can anyone point me in the right direction?
    Last edited by pescadore; January 6th, 2010 at 08:32 PM. Reason: typos

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to monitory drive activity in vb 2008

    It's called the FileWatcher() class, and it monitors folder activity. Its built into the framework.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Nov 2005
    Posts
    10

    Re: How to monitory drive activity in vb 2008

    Here's the answer: From bdbodger at MSDN

    http://social.msdn.microsoft.com/For...?prof=required

    Create a form and add 2 PerformanceCounter controls . For the first one set Catagory property to LogicalDisk , CounterName to Disk Read

    Bytes/sec , InstanceName to _Total for the second PerformanceCounter set CounterName to Disk Write Bytes/sec and the other values the same as

    the first PerformanceCounter . You will need to create 4 small images that you will use with a notifyIcon and add them to your resources such

    as these

    <some graphics shown here>


    Set the form WindowState property to Minimized and the ShowInTaskbar property to false . Add a timer set it's enabled property to true ,

    interval 100 and add a NotifyIcon . Then try this code


    Public Class Form1

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Dim both As Integer = 0
    If (PerformanceCounter1.NextValue > 0) Then
    both += 1
    End If

    If (PerformanceCounter2.NextValue > 0) Then
    both += 2
    End If

    Select Case both
    Case 0
    NotifyIcon1.Icon = My.Resources.blue
    Case 1
    NotifyIcon1.Icon = My.Resources.green
    Case 2
    NotifyIcon1.Icon = My.Resources.green2
    Case 3
    NotifyIcon1.Icon = My.Resources.greengreen
    End Select
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    NotifyIcon1.Icon = My.Resources.blue
    End Sub

    Private Sub NotifyIcon1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles

    NotifyIcon1.MouseClick
    If e.Button = Windows.Forms.MouseButtons.Right Then
    NotifyIcon1.Visible = False
    Application.Exit()
    End If
    End Sub
    End Class

    ___________________________________________________________________________

    Change InstanceName to monitor a particular disk drive .

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [RESOLVED] How to monitory drive activity in vb 2008

    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured