Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GetDiskFreeSpaceEx

GetDiskFreeSpaceEx

Scheduled Pinned Locked Moved C / C++ / MFC
helpperformance
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RickyC
    wrote on last edited by
    #1

    Hy everyone, I'm tryng to do an application that show in some window the current amount of memory in the user's hard disc. But when the user is using win 95 before OSR2 the function GetDiskFreeSpaceEx must be replaced by GetDiskFreeSpace, and the MSDN Library tell's me to "you should dynamically link to it via GetProcAddress"... I do everything they tell me to do... but in win 95 my program do not work... causes an error on kernel32.dll that can't find de GetDiskFreeSpaceExA... please, if someone can help me it's will be great! I'll post an part of my code that I do the implementation of the MSDN Library: P_GDFSE pGetDiskFreeSpaceEx = NULL; pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (GetModuleHandle ("kernel32.dll"),"GetDiskFreeSpaceExA"); if(pGetDiskFreeSpaceEx) { fresult = GetDiskFreeSpaceEx (windowsDir, (PULARGE_INTEGER)&FreeBytesToCaller, (PULARGE_INTEGER)&TotalBytes, (PULARGE_INTEGER)&FreeBytes); m_strDirSistema = _T( windowsDir ); m_dwQuotaLivreUsuario = /*(DWORD*/FreeBytesToCaller / MEGABYTE; // this lines given - me warnings of conversion but it's work correctly m_dwEspacoTotal = /*(DWORD)*/TotalBytes / MEGABYTE; m_dwEspacoLivre = /*(DWORD)*/FreeBytes /MEGABYTE; } thanks all, for the attention! cheers!! and sorry my english, I'm brazilian :):confused:

    J N M 3 Replies Last reply
    0
    • R RickyC

      Hy everyone, I'm tryng to do an application that show in some window the current amount of memory in the user's hard disc. But when the user is using win 95 before OSR2 the function GetDiskFreeSpaceEx must be replaced by GetDiskFreeSpace, and the MSDN Library tell's me to "you should dynamically link to it via GetProcAddress"... I do everything they tell me to do... but in win 95 my program do not work... causes an error on kernel32.dll that can't find de GetDiskFreeSpaceExA... please, if someone can help me it's will be great! I'll post an part of my code that I do the implementation of the MSDN Library: P_GDFSE pGetDiskFreeSpaceEx = NULL; pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (GetModuleHandle ("kernel32.dll"),"GetDiskFreeSpaceExA"); if(pGetDiskFreeSpaceEx) { fresult = GetDiskFreeSpaceEx (windowsDir, (PULARGE_INTEGER)&FreeBytesToCaller, (PULARGE_INTEGER)&TotalBytes, (PULARGE_INTEGER)&FreeBytes); m_strDirSistema = _T( windowsDir ); m_dwQuotaLivreUsuario = /*(DWORD*/FreeBytesToCaller / MEGABYTE; // this lines given - me warnings of conversion but it's work correctly m_dwEspacoTotal = /*(DWORD)*/TotalBytes / MEGABYTE; m_dwEspacoLivre = /*(DWORD)*/FreeBytes /MEGABYTE; } thanks all, for the attention! cheers!! and sorry my english, I'm brazilian :):confused:

      J Offline
      J Offline
      Jon Hulatt
      wrote on last edited by
      #2

      You say that "MSDN Library tell's" [you to] "dynamically link to it via GetProcAddress" But in your code, you're trying to dynamically link to GetDiskFreeSpaceExA, not GetDiskFreeSpace. Sorry to dissapoint you all with my lack of a witty or poignant signature.

      1 Reply Last reply
      0
      • R RickyC

        Hy everyone, I'm tryng to do an application that show in some window the current amount of memory in the user's hard disc. But when the user is using win 95 before OSR2 the function GetDiskFreeSpaceEx must be replaced by GetDiskFreeSpace, and the MSDN Library tell's me to "you should dynamically link to it via GetProcAddress"... I do everything they tell me to do... but in win 95 my program do not work... causes an error on kernel32.dll that can't find de GetDiskFreeSpaceExA... please, if someone can help me it's will be great! I'll post an part of my code that I do the implementation of the MSDN Library: P_GDFSE pGetDiskFreeSpaceEx = NULL; pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (GetModuleHandle ("kernel32.dll"),"GetDiskFreeSpaceExA"); if(pGetDiskFreeSpaceEx) { fresult = GetDiskFreeSpaceEx (windowsDir, (PULARGE_INTEGER)&FreeBytesToCaller, (PULARGE_INTEGER)&TotalBytes, (PULARGE_INTEGER)&FreeBytes); m_strDirSistema = _T( windowsDir ); m_dwQuotaLivreUsuario = /*(DWORD*/FreeBytesToCaller / MEGABYTE; // this lines given - me warnings of conversion but it's work correctly m_dwEspacoTotal = /*(DWORD)*/TotalBytes / MEGABYTE; m_dwEspacoLivre = /*(DWORD)*/FreeBytes /MEGABYTE; } thanks all, for the attention! cheers!! and sorry my english, I'm brazilian :):confused:

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #3

        RickyC wrote: and the MSDN Library tell's me to "you should dynamically link to it via GetProcAddress"... It does nothin of that sort It says "To determine whether GetDiskFreeSpaceEx is available, call the LoadLibrary or LoadLibraryEx function to load the KERNEL32.DLL file, then call the GetProcAddress function to obtain an address for GetDiskFreeSpaceEx. If GetProcAddress fails, or if GetDiskFreeSpaceEx fails with the ERROR_CALL_NOT_IMPLEMENTED code, use the GetDiskFreeSpace function instead of GetDiskFreeSpaceEx" so since you are sure you are on pre-osr2 win 95 dont bother using the GetDiskFreeSpaceEx call and stick to using GetDiskFreeSpace Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

        R 1 Reply Last reply
        0
        • N Nish Nishant

          RickyC wrote: and the MSDN Library tell's me to "you should dynamically link to it via GetProcAddress"... It does nothin of that sort It says "To determine whether GetDiskFreeSpaceEx is available, call the LoadLibrary or LoadLibraryEx function to load the KERNEL32.DLL file, then call the GetProcAddress function to obtain an address for GetDiskFreeSpaceEx. If GetProcAddress fails, or if GetDiskFreeSpaceEx fails with the ERROR_CALL_NOT_IMPLEMENTED code, use the GetDiskFreeSpace function instead of GetDiskFreeSpaceEx" so since you are sure you are on pre-osr2 win 95 dont bother using the GetDiskFreeSpaceEx call and stick to using GetDiskFreeSpace Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

          R Offline
          R Offline
          RickyC
          wrote on last edited by
          #4

          Hy, I'm new to MFC... and don't know much... but in my MSDN Library (january 2001) has something like this: /* Use GetDiskFreeSpaceEx if available; otherwise, use GetDiskFreeSpace. Note: Since GetDiskFreeSpaceEx is not in Windows 95 Retail, we dynamically link to it and only call it if it is present. We don't need to call LoadLibrary on KERNEL32.DLL because it is already loaded into every Win32 process's address space. */ pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress ( GetModuleHandle ("kernel32.dll"), "GetDiskFreeSpaceExA"); if (pGetDiskFreeSpaceEx) { fResult = pGetDiskFreeSpaceEx (pszDrive, (PULARGE_INTEGER)&i64FreeBytesToCaller, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes); if (fResult) { } } else { fResult = GetDiskFreeSpace (pszDrive, &dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, &dwTotalClusters); if (fResult) { //some code that I'll not put because the space in this page } } if (!fResult) printf ("error: %lu: could not get free space for \"%s\"\n", GetLastError(), argv[1]); } I Just try to follow this... and is not working... sorry if I'm doing something stupid :\

          1 Reply Last reply
          0
          • R RickyC

            Hy everyone, I'm tryng to do an application that show in some window the current amount of memory in the user's hard disc. But when the user is using win 95 before OSR2 the function GetDiskFreeSpaceEx must be replaced by GetDiskFreeSpace, and the MSDN Library tell's me to "you should dynamically link to it via GetProcAddress"... I do everything they tell me to do... but in win 95 my program do not work... causes an error on kernel32.dll that can't find de GetDiskFreeSpaceExA... please, if someone can help me it's will be great! I'll post an part of my code that I do the implementation of the MSDN Library: P_GDFSE pGetDiskFreeSpaceEx = NULL; pGetDiskFreeSpaceEx = (P_GDFSE)GetProcAddress (GetModuleHandle ("kernel32.dll"),"GetDiskFreeSpaceExA"); if(pGetDiskFreeSpaceEx) { fresult = GetDiskFreeSpaceEx (windowsDir, (PULARGE_INTEGER)&FreeBytesToCaller, (PULARGE_INTEGER)&TotalBytes, (PULARGE_INTEGER)&FreeBytes); m_strDirSistema = _T( windowsDir ); m_dwQuotaLivreUsuario = /*(DWORD*/FreeBytesToCaller / MEGABYTE; // this lines given - me warnings of conversion but it's work correctly m_dwEspacoTotal = /*(DWORD)*/TotalBytes / MEGABYTE; m_dwEspacoLivre = /*(DWORD)*/FreeBytes /MEGABYTE; } thanks all, for the attention! cheers!! and sorry my english, I'm brazilian :):confused:

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            Download the latest Platform SDK and #include <newapis.h>. That header has wrappers for GetDiskFreeSpaceEx() and other APIs that handle all that linking nonsense for you. :) --Mike-- http://home.inreach.com/mdunn/ While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate. :love: your :bob: with :vegemite: and :beer: Sonork - 100.10414 AcidHelm

            Test out a prerelease build of my Hotfix Checker v2.0! (1

            J 1 Reply Last reply
            0
            • M Michael Dunn

              Download the latest Platform SDK and #include <newapis.h>. That header has wrappers for GetDiskFreeSpaceEx() and other APIs that handle all that linking nonsense for you. :) --Mike-- http://home.inreach.com/mdunn/ While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate. :love: your :bob: with :vegemite: and :beer: Sonork - 100.10414 AcidHelm

              Test out a prerelease build of my Hotfix Checker v2.0! (1

              J Offline
              J Offline
              jerry0davis
              wrote on last edited by
              #6

              Thanks! I've been looking for something just like this for ages. I just which I'd searched the CP Forums sooner! Jeremy Davis http://www.astad.org

              N 1 Reply Last reply
              0
              • N Nish Nishant

                LOL Now we know why you asked a "how to search the forums" doubt-question in the suggestions forum... Nish

                My miniputt high is now 29 I do not think I can improve on that My temperament won't hold www.busterboy.org

                J Offline
                J Offline
                jerry0davis
                wrote on last edited by
                #7

                I tried searching the CodeGuru forums and got loads of rubbish, plus "matches" that basically didn't match! :rolleyes: Jeremy Davis http://www.astad.org

                1 Reply Last reply
                0
                • J jerry0davis

                  Thanks! I've been looking for something just like this for ages. I just which I'd searched the CP Forums sooner! Jeremy Davis http://www.astad.org

                  N Offline
                  N Offline
                  Nish Nishant
                  wrote on last edited by
                  #8

                  LOL Now we know why you asked a "how to search the forums" doubt-question in the suggestions forum... Nish

                  My miniputt high is now 29 I do not think I can improve on that My temperament won't hold www.busterboy.org

                  J 1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups