Announcement

Collapse
No announcement yet.

Getting free space from drives greater than 2 GB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Getting free space from drives greater than 2 GB

    Hello:

    Somebody knows how I get the free space for drives greater than 2GB?
    Actually I use the win API GetDiskFreeSpace function but I don´t if is useful.

    Thanks.


    #2
    Guillermina --
    Microsoft replaced this function to GetDiskFreeSpaceEx, begining from Win95 OSR2 and NT4.
    From Win32.Hlp (4 years ago):
    "The GetDiskFreeSpace function returns incorrect values for volumes that are larger than 2 gigabytes. The function caps the values stored into *lpNumberOfFreeClusters and *lpTotalNumberOfClusters so as to never report volume sizes that are greater than 2 gigabytes.
    Even on volumes that are smaller than 2 gigabytes, the values stored into *lpSectorsPerCluster, *lpNumberOfFreeClusters
    , and *lpTotalNumberOfClusters values may be incorrect. That is because the operating system manipulates the values so that computations with them yield the correct volume size."

    ------------------

    Comment


      #3
      Thanks for the your answer Semen. I´ll try the GetDiskFreeEx function

      ------------------

      Comment


        #4
        Beware... if you explicitly link to the GetDiskFreeSpaceEx() function in your code, your application will not run on Windows 95 (pre OSR2) - it will fail with a "Missing DLL Export" error.

        If this is a problem, then the solution is to use runtime-dynamic-linking instead of loadtime linking. This involves removing the LIB clause from the declaration, using LoadLibrary() to bring an instance of the appropriate DLL into your address space, then a call to GetProcAddress() to get a pointer to the function (a return of zero means that this API is not available), then use CALL DWORD to execute the API. Finally, Freelibrary() is used to clean up the mess.

        If you wish to implement this technique, then search the BBS for "GetDiskFreeSpaceEx" and you should (hopefully) find some example code.


        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎