| | | Forum Newbie
       
Group: Forum Members Last Login: 6/10/2009 8:57:40 AM Posts: 7, Visits: 18 |
| | 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.. |
| | | | Forum Guru
       
Group: Forum Members Last Login: 7/23/2010 8:17:22 PM Posts: 169, Visits: 778 |
| | Have you tried GetFileInformationByHandle? Good Luck |
| | | | 
Forum God
       
Group: Forum Members Last Login: Today @ 11:19:17 AM Posts: 1,795, Visits: 4,572 |
| 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
Keithhttp://www.martin2k.co.uk/forums/index.php?act=idx I've been programming with VB for 14 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning. |
| | | | Forum Newbie
       
Group: Forum Members Last Login: 6/10/2009 8:57:40 AM Posts: 7, Visits: 18 |
| | thanks. I may be wrong but as far as i know this api gives only the logical drive size. As for the example you have shown it gives the total size of c drive only. But i need the total size of harddisk i.e that may contain c,d,e... logical drive |
| | | | 
Forum God
       
Group: Forum Members Last Login: Today @ 11:19:17 AM Posts: 1,795, Visits: 4,572 |
| Shreeti_Tula (6/10/2009) thanks. I may be wrong but as far as i know this api gives only the logical drive size. As for the example you have shown it gives the total size of c drive only. But i need the total size of harddisk i.e that may contain c,d,e... logical driveWell to me the logical size is the actual size. I have a 40GB drive and it shows 40,006,156,288 Bytes and I have 28,899,593,344 Bytes free. I only showed an example using C: drive but you could cycle through all the available fixed drives to find there size. 
Keith http://www.martin2k.co.uk/forums/index.php?act=idx I've been programming with VB for 14 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning. |
| |
|
|