Solved

Free disk space incorrect

Posted on 2007-04-06
3
1,139 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 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