Click to See Complete Forum and Search --> : [RESOLVED] How to monitory drive activity in vb 2008
pescadore
January 6th, 2010, 07:12 PM
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?
dglienna
January 7th, 2010, 03:11 AM
It's called the FileWatcher() class, and it monitors folder activity. Its built into the framework.
pescadore
January 7th, 2010, 08:45 PM
Here's the answer: From bdbodger at MSDN
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/62900f1e-1969-49bb-92cd-4c4eb8c7456d/?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 .
dglienna
January 7th, 2010, 09:39 PM
Or like I said:
http://www.devguru.com/features/tutorials/watchfolderact/watchfolder.asp
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.