Solved

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

Posted on 2003-12-05
12
722 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Application vs Workbook.applicaiton 3 41
VS2015 compilation and missing DLLs 9 161
Messagebox for a Web Site Application 4 77
windbg taking it's time 32 93
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

838 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