Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How to get drive information of your physical media (Hard drive).

Author: Shahzad

This code example shows you how to get the hard drive information using Visual Basic.Net.

Import following namespace.

Imports System.Management

Declare following object variables.

Dim objMOS As ManagementObjectSearcher

Dim objMOC As Management.ManagementObjectCollection

Dim objMO As Management.ManagementObject

Execute query to get results.

objMOS = New ManagementObjectSearcher("Select * From Win32_PhysicalMedia")

objMOC = objMOS.Get

Now get the drive information.

For Each objMO In objMOC

MessageBox.Show("Caption = " & objMO("Caption"))

MessageBox.Show("Drive Name= " & objMO("Name"))

MessageBox.Show("Drive Name= " & objMO("SystemName"))

Next

Dispose object variables.

objMOS.Dispose()

objMOS = Nothing

objMO.Dispose()

objMO = Nothing

Article Comments
check for disk drive

Posted on 6/21/2006 11:58:33 AM by srikanth

I get the following error wjen I try this using XP Professional :An unhandled exception of type 'System.Management.ManagementException' occurred in system.management.dll

Additional information: Not found

Posted on 1/25/2007 12:23:59 PM by Andrea

I am using Visual Studio Microsoft Visual Basic .NET 69461-335-0000007-18071

Do you have code that works on this version?

Posted on 1/25/2007 12:26:08 PM by Andrea

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to get Windows' serial number using Visual Basic.Net.

Disclaimer - Privacy
© 2002-2017 DevASP.net