Problem with win32api function

Tim Roberts timr at probo.com
Sat Apr 14 01:43:12 EDT 2001


Mark Hammond <MarkH at ActiveState.com> wrote:

>Dublanc, David wrote:
>
>> I have a problem with the fonction win32file.GetDiskFreeSpace
>> The maximum number of space is : 65536 bytes. So if the hard disk capacity
>> is > 2 Go, the function returns a wrong result.
>>
>> Do you have solution for this problem ?
>
>Check out the documentation in the help files - the number of bytes is 
>not returned, but 4 different values are to help you calculate it:

I think he realized this.  He's talking about the fourth parameter, total
cylinders, which is limited to 65536.  

He is also correct.  The GetDiskFreeSpace API is defective on Win9X; that's
why GetDiskFreeSpaceEx was invented.  Here, watch this; my 5GB disk gets
reported as 2G:

C:\WINDOWS>ver

Windows 98 [Version 4.10.1998]

C:\WINDOWS>chkdsk

CHKDSK has NOT checked this drive for errors.
You must use SCANDISK to detect and fix errors on this drive.

Volume DURHAM created 06-12-2000 3:25p
Volume Serial Number is 3945-0106

    4,842,144 kilobytes total disk space
    1,451,076 kilobytes free

        4,096 bytes in each allocation unit
    1,210,536 total allocation units on disk
      362,769 available allocation units on disk

      651,264 total bytes memory
      602,976 bytes free

Instead of using CHKDSK, try using SCANDISK.  SCANDISK can reliably detect
and fix a much wider range of disk problems.

C:\WINDOWS>python
Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import win32file
>>> a,b,c,d=win32file.GetDiskFreeSpace('c:\\')
>>> a,b,c,d
(64, 512, 45346, 65526)
>>> print 1L*a*b*d
2147155968
>>> print 1L*a*b*c
1485897728
>>>

C:\WINDOWS>
--
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list