Solved

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

Posted on 2003-12-05
12
730 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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
 
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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

628 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