|
-
Jan 13th, 2000, 03:37 AM
#1
Thread Starter
Frenzied Member
I have made this program to calculate total amount of free space
on a harddrive...BUT!!!
It only goes to 2,147,155,968 bytes!!
I know there is an extended version of the GetDiskFreeSpace...could
anyone help??
Private Declare Function GetDiskFreeSpace Lib "kernel32" _
Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, _
lpSectorsPerCluster As Long, lpBytesPerSector As Long, _
lpNumberOfFreeClusters As Long, _
lpTotalNumberOfClusters As Long) As Long
Private Sub Drive1_Change()
Dim x As Long
Dim SperC As Long
Dim BPerS As Long
Dim NoFC As Long
Dim TNoC As Long
Dim BytesFree As Long
Dim Root As String
Root = Left(Drive1.Drive, 2) & "\"
x& = GetDiskFreeSpace(Root, SperC&, BPerS, NoFC&, TNoC&)
'Fill Labels
Label1.Caption = Format(SperC& * BPerS * NoFC&, "0,000") & " bytes"
Label2.Caption = Format(SperC& * BPerS * NoFC& / 1024000, "0.00") & " MB"
End Sub
-
Jan 13th, 2000, 03:48 AM
#2
The Problem is with your Data Types in the Calculation, not the API, you're multiplying Long Values which have a Max Value of 2,147,483,647, you can use CDbl() to Tell VB to treat the Answer as a Double, giving you a range of upto 1.79769313486232E308, ie.
Code:
Label1.Caption = Format(CDbl(SperC&) * BPerS * NoFC&, "0,000") & " bytes"
Label2.Caption = Format(CDbl(SperC&) * BPerS * NoFC& / 1024000, "0.00") & " MB"
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Jan 13th, 2000, 04:22 AM
#3
Member
Use GetDiskFreeSpaceEx API that is over 2 GB.
Code:
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String,
lpSectorsPerCluster As Long, lpBytesPerSector As Long,
lpNumberOfFreeClusters As Long,
lpTotalNumberOfClusters As Long) As Long
a = the total of free bytes
Code:
Label2.Caption = Format$( a * 10000, "###,###,###,###")
Hope this helps.
[This message has been edited by Ruchi (edited 01-13-2000).]
-
Jan 15th, 2000, 10:35 AM
#4
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|