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
Printable View
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
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