Solved

Free disk space incorrect

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 167
Delphi: Connect to running MS Outlook 4 123
Slow Restore if incremental backups using RDiff.exe 4 31
scroll down TListBox component in Delphi 1 19
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 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