Solved

Free disk space incorrect

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

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

948 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

21 Experts available now in Live!

Get 1:1 Help Now