Thread: GetDiskFreeSpace Windows API fails on windows 2000

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    5

    GetDiskFreeSpace Windows API fails on windows 2000

    Hi All,
    I need to calculate the cluster size using my program.
    Windows provides API - GetDiskFreeSpace, to serve the purpose.
    But the API fails on windows 2000 host giving the following error-
    --------------------
    ERROR_DIR_NOT_ROOT 144 (0x90) :The directory is not a subdirectory of the root directory.
    --------------------
    The same program runs successfully on windows 2003 and above.

    Does anyone knows the solution of this problem?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    The error message seems pretty self-explanatory to me.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    What are you passing as the first parameter?

    Your should really use GetDiskFreeSpaceEx anyway.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #4
    Registered User
    Join Date
    Jun 2009
    Posts
    5
    Quote Originally Posted by iMalc View Post
    What are you passing as the first parameter?

    Your should really use GetDiskFreeSpaceEx anyway.
    Hi iMalc!,
    I can't use GetDiskFreeSpaceEx because i need cluster size.
    Is there any way to calculate cluster size, other than GetDiskFreeSpace ?
    Last edited by dnyampawar; 06-29-2009 at 12:19 AM.

  5. #5
    Registered User
    Join Date
    Jun 2009
    Posts
    5
    Hi,

    Just to make the qustion more clear-

    Here is my code-
    -----------------------------------------------------------------------------------------------------------
    Code:
    #include "stdafx.h"
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    DWORD SectorsPerCluster, BytesPerSector, FreeClusters, TotalClusters;
    
    if (GetDiskFreeSpace(argv[1], &SectorsPerCluster, &BytesPerSector, &FreeClusters, &TotalClusters))
    {
    printf ("GetDiskFreeSpace Success\n");
    }
    else
    {
    printf ("GetDiskFreeSpace Failed : '%d'\n", GetLastError ());
    }
    
    return 0;
    }
    ----------------------------------------------------------------------------------------------------------

    basically, using win2k host , i am trying to access file/directory resided on netapp volume from using UNC path.

    argv[1] is my case is " \\?\UNC\netapp2704\aniket\tempQtree\" for which the API is failing(error code 144).

    whereas, I am able to access " \\netapp2704\aniket\tempQtree\" from file explorer.

    "tempQtree" is qtree on share "aniket".

    The GetDiskFreeSpace API succeeds on the path " \\?\UNC\netapp2704\aniket\ ".

    Hope this clears my question. Please let me know if any additional inputs required.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    GetDiskFreeSpace works on drives, not directories.
    So it must be a root directory, as your results clearly shows.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Jun 2009
    Posts
    5
    Quote Originally Posted by Elysia View Post
    GetDiskFreeSpace works on drives, not directories.
    So it must be a root directory, as your results clearly shows.
    Hi Elysia,
    GetDiskFreeSpace works fine on directories too with Windows 2003 and above.
    It is giving me the correct output on the same path mentioned earlier.

    here is the output -
    ----------------------------
    C:\Documents and Settings\Dnyaneshwar_Pawar\My Documents\Visual Studio Projects\
    GetDiskFreeSpace\Debug>GetDiskFreeSpace.exe \\?\UNC\netapp2704\aniket\tempQtree\
    GetDiskFreeSpace Success
    SectorsPerCluster = 8
    BytesPerSector = 733106
    TotalClusters = 12582912
    ----------------------------

    Thanks!

  8. #8
    Registered User
    Join Date
    Jun 2009
    Posts
    5

    Red face

    anybody??

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  2. Windows API: Edit Box Help
    By Frantic- in forum Windows Programming
    Replies: 2
    Last Post: 08-30-2005, 07:00 PM
  3. Windows messenger API
    By GanglyLamb in forum Windows Programming
    Replies: 0
    Last Post: 07-10-2005, 02:52 AM
  4. MFC or Windows API
    By aresashura in forum Windows Programming
    Replies: 7
    Last Post: 12-01-2001, 10:21 PM
  5. Networking Windows 2000 and Windows Me
    By FCP in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 08-29-2001, 09:10 AM