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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Physical Hard Drive Size

Status
Not open for further replies.

garyriet

Programmer
Apr 24, 2002
2
0
0
US
Hello,
Trying to get the total physical hard drive size for disk 0.
Any help will be welcome.
Thanks
Gary
 
try

Code:
Option Explicit

'In general section
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long

Private Sub Form_Load()
    'KPD-Team 1998
    'URL: [URL unfurl="true"]http://www.allapi.net/[/URL]
    'E-Mail: KPDTeam@Allapi.net

    Dim Sectors As Long, Bytes As Long, FreeC As Long, TotalC As Long, Total As Long, Freeb As Long
    'Retrieve information about the C:    GetDiskFreeSpace "C:\", Sectors, Bytes, FreeC, TotalC
    'Set graphic mode to persistent
    Me.AutoRedraw = True
    'Print the information to the form
    Me.Print " Path: C:\"
    Me.Print " Sectors per Cluster:" + Str$(Sectors)
    Me.Print " Bytes per sector:" + Str$(Bytes)
    Me.Print " Number Of Free Clusters:" + Str$(FreeC)
    Me.Print " Total Number Of Clusters:" + Str$(TotalC)
    Total = TotalC& * Sectors& * Bytes&
    Me.Print " Total number of bytes in path:" + Str$(Total)
    Freeb = FreeC& * Sectors& * Bytes&
    Me.Print " Free bytes:" + Str$(Freeb)
End Sub


or

Code:
Option Explicit

Sub main()
  Dim oFSO As Object
  
  Set oFSO = CreateObject("Scripting.FileSystemObject")
  With oFSO.GetDrive("C:")
    Debug.Print .AvailableSpace
    Debug.Print .DriveLetter
    Debug.Print .DriveType
    Debug.Print .FileSystem
    Debug.Print .FreeSpace
    Debug.Print .IsReady
    Debug.Print .Path
    Debug.Print .RootFolder
    Debug.Print .SerialNumber
    Debug.Print .ShareName
    Debug.Print .TotalSize
    Debug.Print .VolumeName
  End With
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top