Click to See Complete Forum and Search --> : Hard disk info


arnaud vanheu
February 14th, 2000, 04:09 AM
I would like to known how I can found all hard disk on a machine, for every one I search : - the global capacity
- all infos

Chris Eastwood
February 14th, 2000, 09:04 AM
If you use VB6 (or VB5 with the free Microsoft Scripting control from http://msdn.microsoft.com/scripting) - you can use the Scripting RunTime DLL (SCRRUN.DLL) and the FileSystemObject to query this information.

For Example:

1. Set a reference to Microsoft Scripting Run-Time from the Project->References menu in VB

2. Paste the following code into a form with a Button (Command1)



private Sub Command1_Click()
'
Dim oDrive as Drive
Dim oFSO as FileSystemObject
'
set oFSO = new FileSystemObject
'
for Each oDrive In oFSO.Drives
Debug.print oDrive.DriveLetter & " " & _
oDrive.AvailableSpace & " " & oDrive.TotalSize
'
next
End Sub





You might want to checkout the other properties of the Drive object (and all the others that come with the Scripting Host - it's very useful).


Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb