Detect # of Hard Disk?

Worrow

Regular
Joined
Jul 10, 2003
Messages
68
Is there any way to detect the number of HD using VB .NET? I have managed to get the number of all disk drive(floppy, HD, CD) with Management Object Collection. But couldn't tell which one is which. Any idea?
 
Somthing like below

imports.system.management

...
Dim diskClass As _
New ManagementClass("Win32_LogicalDisk")
Dim disks As ManagementObjectCollection = _ diskClass.GetInstances()
Dim disk As New ManagementObject

For Each disk In disks
Label1.Text &= disk.Properties("Name").ToString & vbCrLf
Next disk

-------------------------------------------------------------------------------
The codes above only shows all the drive letters, nothing more.
 
Use System.Environment.GetLogicalDrives()

It will retun an array of strings

it will give you A:/

C:/
D:/
etc ...
but will not include CD drives
only floppy, harddisks,newtork drives..

Hope this helps..
 
Back
Top