Why Diskspace() May Return Incorrect Result

Last reviewed: June 27, 1995
Article ID: Q124301
The information in this article applies to:
  • Microsoft FoxPro for Windows, version 2.6a

SUMMARY

Page L3-451 of the FoxPro "Language Reference" explains that the value returned by DISKSPACE() may not be accurate for large network drives. This is true for any drive over 256 megabytes in size. However, the reason for this is not documented. This article provides that reason.

MORE INFORMATION

The reason is that DISKSPACE() uses an MS-DOS System call that returns 16-bit values, thus limiting the size of the returned value to 65,535.

The DISKSPACE() function uses INT 21h FUNCTION 36h to determine the number of sectors per cluster, available clusters, bytes per sector, and total number of clusters on a specified drive. Because this function returns a 16- bit result, DISKSPACE() may report incorrect information about large (over 256 megabytes) drives.

For example, a two-gigabyte drive with a 4,000-byte cluster size has 512,000 clusters, which is much bigger than the 65,535 maximum return value. The system either reports that the clusters are much bigger than they really are, or it reports that there are many fewer clusters than there actually are. In either case, the incorrect report causes the DISKSPACE() result to be off. In this example, DISKSPACE() reports that the maximum free space for a two-gigabyte drive as 256 megabytes.


Additional reference words: FoxWin 2.60a
KBCategory: kbenv kbdocerr
KBSubcategory: FxenvHw


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 27, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.