Solved

Free disk space incorrect

Posted on 2007-04-06
3
1,136 Views
Last Modified: 2010-04-05
I am using Delphi 3 and am having trouble determining the amount of free disk space on my 40gb hard drive's drive letter C.  I am using the following code...

var
  freeSpace : Double;
  s: Char;
begin
  // Drive letter
  s := 'C';
  freeSpace  := DiskFree(Ord(s) - 64);

Unfortunately freeSpace comes back as 1,687,274,496  when in fact the correct free disk space, according to a command prompt DIR  is...

 86 Dir(s)  10,278,877,696 bytes free

Any idea what I'm doing wrong?



0
Comment
Question by:Kapusta
3 Comments
 
LVL 28

Accepted Solution

by:
TName earned 25 total points
ID: 18868694

>I am using Delphi 3

In D3 DiskFree() apparently returns an Integer, so your (too large) value will wrap...
(to make sure: Have you control-clicked on the function name (DiskFree) to see the return data type?)

See also:
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_10054667.html
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_10170937.html
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_10302824.html
0
 
LVL 5

Assisted Solution

by:xr1140
xr1140 earned 25 total points
ID: 18869323

The DiskSize and DiskFree properties returns incorrect values for volumes that are larger than 2 gigabytes  because Delphi 2 and 3 don't support 64-bit integer operations.
0
 

Author Comment

by:Kapusta
ID: 18869805
Unfortunately there is no solution for Delphi3.  I will just have to give up.  The other 'See also' links do not provide any workable solution for D3.  The one solution found in Q_10302824 is not a solution since it is not possible to use the value with other standard D3 data types in math operations.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

19 Experts available now in Live!

Get 1:1 Help Now