|
-
January 6th, 2010, 08:12 PM
#1
[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
-
January 7th, 2010, 04:11 AM
#2
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.
-
January 7th, 2010, 09:45 PM
#3
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 .
-
January 7th, 2010, 10:39 PM
#4
Re: [RESOLVED] How to monitory drive activity in vb 2008
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|