5 pts.
 VB6 kernal func GetFreeDiskSpace returns a Long (not long enough)
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

Software/Hardware used:
ASKED: May 11, 2009  8:12 PM
UPDATED: May 12, 2009  2:38 PM

Answer Wiki:
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>
Last Wiki Answer Submitted:  May 12, 2009  2:38 pm  by  Vatchy   1,410 pts.
All Answer Wiki Contributors:  Vatchy   1,410 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _