Shreeti_Tula (6/9/2009) I know there are lots of question being asked about this but i still have not found the solution. Can anybody help to find the total size of hard disk not the logical size. GetDiskFreeSpaceEx only helps to get the logical size. Please help..Well I've always used GetDiskFreeSpaceEx API to get the total drive size and the free space, its always worked for me. Option Explicit
Dim Status As Long Dim TotalBytes As Currency Dim FreeBytes As Currency Dim BytesAvailableToCaller As Currency Dim DiskSize As String Dim DiskSpace As String
Private Declare Function cc Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpDirectoryName As String, lpFreeBytesAvailableToCaller As Currency, _ lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long
Private Sub Command1_Click
Status = GetDiskFreeSpaceEx("C:\", BytesAvailableToCaller, TotalBytes, FreeBytes) If Status = 0 Then DiskSize = "Unknown" DiskSpace = "Unknown" Else DiskSize = Format(TotalBytes * 10000, "#,##0") & " Bytes" DiskSpace = Format(FreeBytes * 10000, "#,##0") & " Bytes" End If
MsgBox "Disk Size: " & DiskSize MsgBox "Free Space: " & DiskSpace
End Sub
KeithI've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
|