VB6 kernal func GetFreeDiskSpace returns a Long (not long enough)

5 pts.
Tags:
VB6
Visual Basic
I have a VB6 kernal func which returns free space as a long, but the max val for a long is 2.1 meg and I have 140 gig free. Is there a func or sub that returns free space as currency? Current func follows: ------------------------------------------------------------------------------------------------------ Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long Public Function GetFreeSpace(pDrive As String) As Currency Dim curTotalBytes As Currency Dim curFreeBytesToCaller As Currency Dim curTotalFreeBytes As Currency Call GetDiskFreeSpaceEx(pDrive, curFreeBytesToCaller, curTotalBytes, curTotalFreeBytes) GetFreeSpace = curTotalFreeBytes End Function

Answer Wiki

Thanks. We'll let you know when a new response is added.

Use the FileSystemObject. Here is an example. Create a new project and add a label to the form. Paste this code and run it:

<pre>Private Sub Form_Load()
Label1.Caption = Get_Free_Space(“C:”)
End Sub

Public Function Get_Free_Space(DrvPath)
Dim FS
Dim D
Dim s

Set FS = CreateObject(“Scripting.FileSystemObject”)
Set D = FS.GetDrive(FS.GetDriveName(FS.GetAbsolutePathName(DrvPath)))
s = Str(D.AvailableSpace)
Get_Free_Space = s
End Function</pre>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following