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.

DouglasHoltAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
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.
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.
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

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
shivsaCommented:
also u can try the code from here.
http://blackbeltvb.com/
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.
shivsaCommented:
GET_DISK_SPACE is from this site.
http://www.neurophys.wisc.edu/ravi/software/diskspace/
shivsaCommented:
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.
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DouglasHoltAuthor Commented:
Thanks much!  I'll look into that info and get back with you...
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!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.