How do I get the free space on the CDROM?

This is a discussion on How do I get the free space on the CDROM? within the C++ Programming forums, part of the General Programming Boards category; I currently made this code: #include <iostream.h> #include <afx.h> #include <windows.h> Code: #define MAX_OF_HARD_DISKS 24 static char HardDiskLetters[MAX_OF_HARD_DISKS][4]={ "c:\", "d:\", ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    104

    How do I get the free space on the CDROM?

    I currently made this code:


    #include <iostream.h>
    #include <afx.h>
    #include <windows.h>

    Code:
    #define MAX_OF_HARD_DISKS   24 
    static char HardDiskLetters[MAX_OF_HARD_DISKS][4]={ 
       "c:\\",   "d:\\",   "e:\\",   "f:\\",   "g:\\",   "h:\\", 
       "i:\\",   "j:\\",   "k:\\",   "l:\\",   "m:\\",   "n:\\", 
       "o:\\",   "p:\\",   "q:\\",   "r:\\",   "s:\\",   "t:\\", 
       "u:\\",   "v:\\",   "w:\\",   "x:\\",   "y:\\",   "z:\\" 
    }; 
    
    
    int main() 
    { 
       ULARGE_INTEGER AvailableToCaller, Disk, Free; 
       int iCounter; 
       CString Temp; 
    
       for(iCounter=0;iCounter<MAX_OF_HARD_DISKS;iCounter++) 
       { 
          if(GetDriveType(HardDiskLetters[iCounter])==DRIVE_CDROM) 
          { 
             cout << HardDiskLetters[iCounter] << endl; 
    
             GetDiskFreeSpaceEx(HardDiskLetters[iCounter],&AvailableToCaller,&Disk, &Free); 
    
             Temp.Format("Free: %I64d (MB)\r\n",Free.QuadPart/1024/1024); 
    
             cout << Temp << endl; 
    
          } 
    
       } 
       return 0; 
    }
    But it always returns 0 MB on whatever CD I put...

    Any ideas?

    Thanks!
    Ilia Yordanov,
    http://www.cpp-home.com ; C++ Resources

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662
    640 - <used space>

    If you are doing this for multi-sessioned CD-R's then you may want to use 700 or 800.


    gg

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    104
    I don't understand... please, explain what you mean... yes, I know that regular CDs are 640 MB, but what does this have to do with my question or my code?

    Thanks!
    Ilia Yordanov,
    http://www.cpp-home.com ; C++ Resources

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662
    Code:
    <free space> + <used space> = <total space>
    Therefore,
    <total space> - <used space> = <free space>
    Where <used space> is "Disk" in your code.

    What exactly do you need explained? Perhaps I don't understand the question.

    gg

  5. #5
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    There is no empty space on a finished CD... no matter how much data is on it.
    Away.

  6. #6
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,662
    GetLogicalDrives() would be a little better than looping through "HardDiskLetters".

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Out of space when compiling kernel
    By NuNn in forum Linux Programming
    Replies: 3
    Last Post: 04-01-2009, 02:43 PM
  2. Free Store of memory
    By George2 in forum C++ Programming
    Replies: 6
    Last Post: 11-12-2007, 01:27 PM
  3. Why should I use the Free Space (heap)
    By BlackSlash12 in forum C++ Programming
    Replies: 8
    Last Post: 09-09-2007, 06:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21