Solved

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

Posted on 2003-12-05
12
712 Views
Last Modified: 2013-12-03
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
Comment
Question by:DouglasHolt
  • 6
  • 5
12 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9887332
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9887350
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
 

Author Comment

by:DouglasHolt
ID: 9887352
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9887354
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
 
LVL 24

Expert Comment

by:shivsa
ID: 9887395
also u can try the code from here.
http://blackbeltvb.com/
0
 

Author Comment

by:DouglasHolt
ID: 9887449
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 24

Expert Comment

by:shivsa
ID: 9887462
GET_DISK_SPACE is from this site.
http://www.neurophys.wisc.edu/ravi/software/diskspace/
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9887467
0
 

Author Comment

by:DouglasHolt
ID: 9887473
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
 
LVL 48

Accepted Solution

by:
AlexFM earned 500 total points
ID: 9887536
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
 

Author Comment

by:DouglasHolt
ID: 9887624
Thanks much!  I'll look into that info and get back with you...
0
 

Author Comment

by:DouglasHolt
ID: 9888357
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now