Thread: Check for a blank cd-r

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    10

    Question Check for a blank cd-r

    Could anyone give me a clue or some example on how do i check if a blank cd is inserted in my cd/rw drive? I'm trying to write a little program where i punch F1 key, and my cd/rw opens, then msg box says insert a blank cd, then i click ok. Here i need to check if the media inserted is a valid blank cd-r. If not it would spit it out and return to the first msg box. If it's valid cd-r, it would write the specific files (listed in the masterlist file, which would be quite big) onto the cd-r, then spit it out, display message saying it's done. If error during the session, it would spit it out saying error occured, asking if i want to insert another blank cd-r and start over. While copying files to cd-r it would show the progress bar or some kind of animation of the copy process.

    I've got it to the point where it hides the console, opens the cd tray, displays me the msg box to insert a blank cd-r, after clicking on OK it closes the CD/RW, and so on.

    Code:
    #include <iostream> 
    #include <windows.h> 
    #include <mmsystem.h>
    using namespace std;
    
    int open_cd();
    int close_cd();
    
    int main() 
    {
    	FreeConsole();
    	open_cd();
    	MessageBox(NULL, "Insert Blank CD", "Back-up program", MB_OK);
    	
    	close_cd();
    	Sleep(3000);
    	open_cd();
    	MessageBox(NULL, "Done! Remove a CD and click OK", "Back-up program", MB_OK);
    	close_cd();
    
    	return 0;
    }
    
    int open_cd()
    {
    	mciSendString("set cdaudio door open",NULL,0,NULL);
    	return 0;
    }
    
    int close_cd()
    {
    	mciSendString("set cdaudio door closed",NULL,0,NULL);
    return 0;
    }

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    This is very specific. I would suggest looking through the Windows API. Look through the source code of cdrdao, cdrecord, or some cd recording library. (Granted, these programs are linux programs, but the basic method should be the same.)

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    10
    Do you know the url i could look it up?

    If I understand it correctly, the CD/RW drive should returm some kind of reply that I could compare and decide whether to procede or return to the first msg box. I think i have to make a while loop so it would return to the msg box and opening-closing till the valid blank cd-r is detected.

    I have never worked with linux. As I understand the C++ methods in linux are the same as if I code in VS 6.0?

    --------------------------------------------------------------------------
    There are some things I wish I didn't know, there are some things I wish I knew. Go figure...

    My parents named me Valdis
    I chose my name to be Waldis
    Everybody decided to call me Val
    It's that simple

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    10
    ------------------------------------------------
    There are some things I wish I didn't know, there are some things I wish I knew. Go figure...

    My parents named me Valdis
    I chose my name to be Waldis
    Everybody decided to call me Val
    It's that simple

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. undefined reference
    By 3saul in forum Linux Programming
    Replies: 12
    Last Post: 08-23-2006, 05:28 PM
  2. Deleting objects show no drop in memory usage.
    By theJ89 in forum C++ Programming
    Replies: 8
    Last Post: 04-02-2006, 06:21 AM
  3. Check application visibility
    By 3saul in forum Linux Programming
    Replies: 2
    Last Post: 02-13-2006, 05:13 PM
  4. MCI CD Player
    By soutine in forum Windows Programming
    Replies: 0
    Last Post: 11-02-2001, 05:03 PM
  5. CD Boot - Need Help
    By (TNT) in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-19-2001, 12:29 PM