Solved

Free disk space incorrect

Posted on 2007-04-06
3
1,141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

710 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