Solved

FSO gives wrote TotalSize

Posted on 2000-03-16
11
204 Views
Last Modified: 2008-03-04
I'm trying to write a little app to give FreeSpace/TotalSize for my HDs

The HDs are around 2.5, 3.5 and 3, but Total size always gives around 1.99

What am I missing? The drives are Fat32 and I'm using VB6 sp3 and scrrun.dll is 5.1.0.4615

PC is using Win98
0
Comment
Question by:JOK
  • 6
  • 5
11 Comments
 
LVL 3

Author Comment

by:JOK
ID: 2625709
..sorry, should be "wrong TotalSize"

maybe I should check my code for a typo ;)
0
 
LVL 9

Accepted Solution

by:
Ruchi earned 109 total points
ID: 2625714
GetDiskFreeSpaceEX API is for getting the total space of hard drive -- more than 2 GB

Option Explicit

Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long
Private Function GetFreeSpace(pDrive As String) As String
    Dim curTotalBytes As Currency
    Dim curFreeBytesToCaller As Currency
    Dim curTotalFreeBytes As Currency
     
    Call GetDiskFreeSpaceEx(pDrive, curFreeBytesToCaller, curTotalBytes, curTotalFreeBytes)
    GetFreeSpace = Format$(curTotalBytes * 10000, "###,###,###,##0")
End Function

Private Sub Form_Load()
MsgBox "Free space on drive C: is: " & GetFreeSpace("C:")
End Sub
0
 
LVL 3

Author Comment

by:JOK
ID: 2625740
I hate fast answers. Makes me feel dumber than I am.

It worked.

I couldn't find anything on msdn. Guess I didn't know what to search for.
0
 
LVL 3

Author Comment

by:JOK
ID: 2625743
You've got the points already, but what about for available space. Would using FSO work or is there the same limit?
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2625746
Thank you very much, JOK, for the points! I am glad that I could be of any help to you! Again, thanks!

Just logged on a few minutes ago. ;-)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:Ruchi
ID: 2625755
Yes.....

Increase more points!! ;-)

Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long
Private Function GetFreeSpace(pDrive As String) As String
    Dim curTotalBytes As Currency
    Dim curFreeBytesToCaller As Currency
    Dim curTotalFreeBytes As Currency
    Call GetDiskFreeSpaceEx(pDrive, curFreeBytesToCaller, curTotalBytes, curTotalFreeBytes)
    GetFreeSpace = Format$(curTotalFreeBytes * 10000, "###,###,###,##0")
End Function

Private Sub Command1_Click()
MsgBox "Free space on drive C: is: " & GetFreeSpace("C:")
End Sub
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2625806
JOK,
Just kidding about increasing more point! Anyway, did you get working for available space on your hard drive? Please let me know. Thank you very much.
0
 
LVL 3

Author Comment

by:JOK
ID: 2628439
Looks like its working for both.

I've used FSO with ASP and it seems to work properly.

I can give you more points if you can tell me if, in fact it does work with ASP, or why it doesn't.
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2629590
JOK: I don't know anything about ASP. I really can't help you with this ASP question. Sorry.
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2629601
ASP - Active Server Page? I am not a web developer.
0
 
LVL 3

Author Comment

by:JOK
ID: 2631348
With ASP, you can us VBScript which is a "subset" of VB. FSO is FileSystemObject, and you can use it with VB or VBScript.

Oh well. I really appreciate your help, 'tho.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now