ejecting multiple cd-rom drives

This is a discussion on ejecting multiple cd-rom drives within the Windows Programming forums, part of the Platform Specific Boards category; hi! i know that this code ejects a 1st cd-rom drive : mciSendString("open cdaudio alias cd1", 0, 0, 0); mciSendString("set ...

  1. #1
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    362

    ejecting multiple cd-rom drives

    hi!

    i know that this code ejects a 1st cd-rom drive :

    mciSendString("open cdaudio alias cd1", 0, 0, 0);
    mciSendString("set cd1 door open wait", 0, 0, 0);

    but how can i eject a 2nd and a 3rd cd-rom drive?
    i tried this code and failed:

    mciSendString("open cdaudio1 alias cd2", 0, 0, 0);
    mciSendString("set cd2 door open wait", 0, 0, 0);
    mciSendString("open cdaudio2 alias cd3", 0, 0, 0);
    mciSendString("set cd3 door open wait", 0, 0, 0);

    please help.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Code:
    #include <windows.h>
    #include <stdio.h>
    #include <tchar.h>
    
    #if defined(_MSC_VER)
    #  pragma comment(lib, "winmm.lib")
    #endif
    
    void EjectAll(void)
    {
    	TCHAR command[1000];
    	TCHAR result[1000];
    	UINT  count;
    	UINT  i;
    
    	/* Get the number of cdaudio devices available. */
    	mciSendString(TEXT("sysinfo cdaudio quantity"), result, 1000, NULL);
    	count = _tcstoul(result, NULL, 10);
    
    	for (i = 1; i <= count; i++)
    	{
    		/* Get the name of this device. */
    		wsprintf(command, TEXT("sysinfo cdaudio name %u"), i);
    		mciSendString(command, result, 1000, NULL);
    
    		/* Open this device. */
    		wsprintf(command, TEXT("open %.500s alias cd1"), result);
    		mciSendString(command, NULL, 0, NULL);
    
    		/* Eject this device. */
    		mciSendString(TEXT("set cd1 door open wait"), NULL, 0, NULL);
    
    		/* Close this device. */
    		mciSendString(TEXT("close cd1"), NULL, 0, NULL);
    	}
    }
    
    int main(void)
    {
    	EjectAll();
    	getchar();
    	return 0;
    }

  3. #3
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    362
    i'll try that. Thanx a bunch.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Nested for loop...search & display a list within a list
    By chadsxe in forum C++ Programming
    Replies: 13
    Last Post: 07-20-2005, 01:34 PM
  2. HUGE fps jump
    By DavidP in forum Game Programming
    Replies: 23
    Last Post: 07-01-2004, 10:36 AM
  3. CD rom troubles...
    By Shadow in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 11-08-2003, 09:56 PM
  4. SCSI drivers... device conflict... no CD drives
    By CodeMonkey in forum Tech Board
    Replies: 2
    Last Post: 09-10-2003, 06:48 AM
  5. Probs with CD drives
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 03-11-2002, 10:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21