Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View Logical Drives 1

Status
Not open for further replies.

camjon

Technical User
Apr 2, 2008
17
US
Does anyone know how you can view the logical drives on your computer using VBA, I am having a lot of trouble starting out.
 
You may use WMI (the Win32_LogicalDisk class).

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV.
I have just one more question, can you use the WMI (the Win32_LogicalDisk class) with version 6.
 
with version 6 of what ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
A starting point:
Code:
Dim objWMIService, colItems, objItem
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk", "WQL", &H30)
For Each objItem In colItems
  Debug.Print "Caption: " & objItem.Caption & ", DeviceID: " & objItem.DeviceID & ", Name: " & objItem.Name
  Debug.Print "Description: " & objItem.Description
  Debug.Print "ProviderName: " & objItem.ProviderName
  Debug.Print "VolumeName: " & objItem.VolumeName & ",VolumeSerialNumber: " & objItem.VolumeSerialNumber
  Debug.Print "FreeSpace: " & objItem.FreeSpace & ", Size: " & objItem.Size
  Debug.Print
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top