Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 735
  • Last Modified:

How to get the available space on a CD-R/CD-RW disk?

In Windows XP, how can I get the available space on a CD-R/CD-RW disk?
GetDiskFreeSpace and GetDiskFreeSpaceEx both return 0.
Using Scripting.FileSystemObject results in 0.

When I look at the drive in the Explorer, it tells me the Total Size and Free Space.  How can I get this information?  Any help will be appreciated.  BTW, I'm using Visual C++ 6.0 on WinXP Pro.

0
DouglasHolt
Asked:
DouglasHolt
  • 6
  • 5
1 Solution
 
shivsaCommented:
Try

ULARGE_INTEGER free;
ULARGE_INTEGER total;
ULARGE_INTEGER totalfree;

GetDiskFreeSpaceEx("\<path to cd drive>",&free,&total,&totalfree);

Note that according to the docs, you must follow the path with an additional backslash.
0
 
shivsaCommented:
u can read this full document for details.
http://www.neurophys.wisc.edu/ravi/software/diskspace/

if they return 0, it means command passed and u have to check the values for free/total/totalfree variables.
0
 
DouglasHoltAuthor Commented:
Thanks, but in my question I mentioned that GetDiskFreeSpaceEx results in 0.  I use GetDiskFreeSpaceEx, and it works for all drive types except the CD.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
shivsaCommented:
also try int GET_DISK_SPACE(char *,float *,float *,float *)

where the drive name must be specified in the form of it's root directory name (e.g. c:\ or d:\) and all other values are returned by the routine. The return value is 0 for success, and non-zero for an error condition.
The four arguments are interpreted as follows:

       1st   :   Root Directory of Disk Drive (e.g. c:\ or d:\)
       2nd   :   Available Space in Megabytes
       3rd   :   Total Space in Megabytes
       4th   :   Free Space in Megabytes

The root directory name must be supplied, while the three space values are returned by the routine
0
 
shivsaCommented:
also u can try the code from here.
http://blackbeltvb.com/
0
 
DouglasHoltAuthor Commented:
Again, thanks, but all of the above answers use GetDiskFreeSpaceEx and I can't find any information on GET_DISK_SPACE.  The sample from BlackBeltVB uses GetDiskFreeSpaceEx as well.
0
 
shivsaCommented:
GET_DISK_SPACE is from this site.
http://www.neurophys.wisc.edu/ravi/software/diskspace/
0
 
shivsaCommented:
0
 
DouglasHoltAuthor Commented:
The above two comments both resolve down to GetDiskFreeSpaceEx, which doesn't work.  I'm looking for any answer that does not involve GetDiskFreeSpaceEx, thanks.
0
 
AlexFMCommented:
This information depends on the way of CD burning. If you are using built-in Windows XP CD burning support, check out this sample:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vctchvisualcplusplusmsdnarticles.asp
CD Burning Sample Application
Demonstrates the new Windows® XP Image Mastering API used to enable your application to burn data and audio CDs.

I beleive this API can help:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/idiscrecorder_querymediainfo.asp

If you are using Nero, NeroGetCDInfo does the job:
http://oldlook.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20738720.html

GetDiskFreeSpaceEx is not supported by CD burning drivers.
0
 
DouglasHoltAuthor Commented:
Thanks much!  I'll look into that info and get back with you...
0
 
DouglasHoltAuthor Commented:
AlexFM,

  I was able to use the wrapper classes for IDiscMaster etc work.  This is exactly what I needed and more!  Now I can do the actual burning without relying on the shell and the user to do the right thing with it.  Perfect!!!  Thanks a bunch!  Now if only we could get MS to port this back to Windows 2000, 98, NT 4.0, etc.  <dream on!>  Fortunately, for other reasons we're already requiring Windows XP, so I'm golden!
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now