CDR.EXE - Open/Close CD Drive(s) Programmatically

In Windows Explorer, you can right-click on a CD-Drive and select the "Eject" option to open the CD Drive. Unfortunately, there is no "Close" equivelant to Close the drive. This project builds a command-line program that lets you open or close any or all of your CD-Drives.

To display the program's usage, run the program with no parameters:

C:\> CDR
CDR by Chris M. Sebrell
usage:
 CDR [open|close] [Drive-Letter|ALL]
example:
 CDR open E:
 CDR close ALL
C:\>

To OPEN or CLOSE the first logical CD Drive:
C:\> CDR open
C:\> CDR close

If you have more than one CD Drive, you can specify a drive letter:

C:\> CDR open g:
C:\> CDR close g:

If you have more than one CD Drive, you can specify ALL drives:

C:\> CDR open all
C:\> CDR close all

The main work routine in the program is CD_OpenClose(BOOL bOpen, TCHAR cDrive)

//Open or Close CD Drive
//cDrive is Drive Letter to Open, or 0x01 for 'Default' drive
//Examples:
//CD_OpenCloseDrive(TRUE, 'G');  //Open CD Door for Drive G: 
//CD_OpenCloseDrive(FALSE, 'G'); //Close CD Door for Drive G:
//CD_OpenCloseDrive(TRUE, 1);    //Open First Logical CD Door
void CD_OpenCloseDrive(BOOL bOpenDrive, TCHAR cDrive)
{
 MCI_OPEN_PARMS op;
 MCI_STATUS_PARMS st;
 DWORD flags;

 TCHAR szDriveName[4];
 strcpy(szDriveName, "X:");

 ::ZeroMemory(&op, sizeof(MCI_OPEN_PARMS));
 op.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;

 if(cDrive > 1)
 {
  szDriveName[0] = cDrive;
  op.lpstrElementName = szDriveName;
  flags = MCI_OPEN_TYPE 
        | MCI_OPEN_TYPE_ID 
        | MCI_OPEN_ELEMENT 
        | MCI_OPEN_SHAREABLE;
 }
 else flags = MCI_OPEN_TYPE 
            | MCI_OPEN_TYPE_ID 
            | MCI_OPEN_SHAREABLE;

 if (!mciSendCommand(0,MCI_OPEN,flags,(unsigned long)&op)) 
 {
  st.dwItem = MCI_STATUS_READY;

  if(bOpenDrive)
   mciSendCommand(op.wDeviceID,MCI_SET,MCI_SET_DOOR_OPEN,0);
  else
   mciSendCommand(op.wDeviceID,MCI_SET,MCI_SET_DOOR_CLOSED,0);

  mciSendCommand(op.wDeviceID,MCI_CLOSE,MCI_WAIT,0);
 }
}

Next, to facilitate operating on ALL CD Drive Doors, add this routine (which calls the CD_OpenCloseDrive() function above):

void CD_OpenCloseAllDrives(BOOL bOpenDrives)
{
 // Determine All CD Drives and Open (or Close) each one
 int nPos = 0;
 UINT nCount = 0;
 TCHAR szDrive[4];
 strcpy(szDrive, "?:\\");

 DWORD dwDriveList = ::GetLogicalDrives ();

 while (dwDriveList) {
  if (dwDriveList & 1) 
  {
   szDrive[0] = 0x41 + nPos;
   if(::GetDriveType(szDrive) == DRIVE_CDROM)
   CD_OpenCloseDrive(bOpenDrives, szDrive[0]);
  }
  dwDriveList >>= 1;
  nPos++;
 }
}

That's all! The download includes source code & the compiled CDR.EXE program. If anyone has additions, corrections, or a whole new approach to this, I'd love to hear about it. I'll update this project with any new useful information I receive.

Downloads

Download project (Source & Executable)- 32 Kb


Comments

  • 2013 fascination and entertainment goods online on wonderful, Seize more you products onw

    Posted by Glonesciece on 06/24/2013 04:31pm

    Anyone who says that sparkle and glitter are a trend of the past, clearly hasn't met our friend, Jimmy.The Candy Clutchand Viola Crystal Sandals by Jimmy Choowill ensure that all eyes are on youwhen strutting downthe VIP carpet (even ifthe closestthing to paparazzi you encounter are the photo-ops of you and your girlfriends at club.) We've all heard the saying, "When in Rome, do as the Romans do." With the Moro Napa Roma Bagand Strappy Platform Sandals by [url=http://www.reelia.co.uk/]http://www.reelia.co.uk/[/url] Bottega [url=http://www.reelia.co.uk/]http://www.reelia.co.uk/[/url] Veneta, you can accomplish just that. The strappy details of the shoes are a contemporary take on traditional gladiator-style footwear, and the spacious woven tote keeps your belongings in check as you make your way toward the nearest trattoria. Fame and Fortune Cosmopolitan Chic Alexander McQueenaces this concept with their Folklore de Manta Clutchand Cut-out College Bootie. The contrast of the floral printagainst the details of the moremasculine mountaineer bootiebrings variety toan outfit, whilemaintaining arural (yet flirty) appeal. For decades, handbags and shoes have been renowned partners in crime; by complimenting one another, they unveil the hidden potential lurking behind many [url=http://www.reelia.co.uk/]karen millen online[/url] underrated wardrobe staples. Fierce [url=http://www.reelia.co.uk/]http://www.reelia.co.uk/[/url] footwear coupled with an equally chic bag creates such a successful tag-team duo due to their uncanny ability to bring balance to the eye. A smart way to achieve this harmony is by looking to a single designer for each of these fundamental accessory pieces.No matter how you accessorize-- either perfectly matched, orwith subtle [url=http://www.reelia.co.uk/]http://www.reelia.co.uk/[/url] differences--we've gota few picks thataim tomirror thisbalance inyour next ensemble: Rebecca Minkoffunderstands thatpenciling in wardrobe changes in the middle ofourdaily routine isn't always a possibility, which is why theMorning After Clutch (MAC) andthe M.A.B. Cut-out Flatsin basic black make the perfect day-to-night twosome. For those who adore attention-grabbing accessories, Diane Von Furstenberghas theeclectic flair that keeps your closetstylish and unique. The bold print on thePenny Canvas Large Bagand Krista Printed Leather Sandalsmake the perfect statement piecesforyour favoritelittle black dress. Safari Sunset Vixen on Vacation Floral Expedition

    Reply
  • people cup 2014 brazil soccer jerseys boonies exaltation coming this biggest soccer party.

    Posted by Merejensejage on 06/21/2013 06:04am

    Ferguson said: "We are delighted to have Rio fit again and back in contention. He's been having spasms and has missed the last [url=http://www.worldcupsoccerfacts.info/]http://www.worldcupsoccerfacts.info/[/url] few games and that's given us an opportunity to get it settled down. Sir Alex Ferguson believes Rio Ferdinand's return to fitness will give his side a psychological edge going into Sunday's crucial clash with Chelsea at Old Trafford. Ferdinand has been missing for the champions since suffering back spasms in the middle of last month. United have coped well without the England defender but Ferguson knows his return for the visit of Chelsea is a huge boost ahead of a game that promises to influence the outcome of the title race. While Chelsea have spent millions since the arrival of Roman Abramovich, Ferguson insists he will not change his philosophy of building successful teams without breaking the bank at Old Trafford. Liverpool sit top on 45 points, with Chelsea three points adrift. United, with two games in hand, have 38 - a tally shared by fourth-placed Aston Villa. Ferguson added: "The two games in hand we [url=http://www.worldcupsoccerfacts.info/]http://www.worldcupsoccerfacts.info/[/url] have gives us an opportunity to close the gap (on leaders Liverpool). There is no question those are important games and we have to take advantage of them. Ferguson has challenged United to make full use of their home advantage against Chelsea and take a significant step towards another Premier League title. United have enjoyed a successful season on home soil as well as having played Chelsea, Arsenal and Liverpool away from home. Ferguson, who has a fully fit squad to choose from with the exception of Wes Brown, knows his side can score another psychological victory over Chelsea with a win. "But we need to focus on the challenge of Chelsea first. Our home [url=http://www.worldcupsoccerfacts.info/]2014 world cup soccer jerseys[/url] form this season and record has been great again. Chelsea have always had a good record at Old Trafford. This is a big game and we need to meet the challenge." "He's trained for the past few days and feels fine. You always benefit from having your best players available and he's one of the best in the world. There's no question about that. We are lucky to have some good young players here to come in and replace him, but having Rio back makes [url=http://www.worldcupsoccerfacts.info/]brazil world cup jerseys[/url] a difference because of his stature and presence." He added: "Chelsea changed the face of the Premier League and to win the title back off them was important for us. We are building a team here that should last for a long time. We know we can't match the spending power of Chelsea and have to identify young players. [url=http://www.worldcupsoccerfacts.info/]http://www.worldcupsoccerfacts.info/[/url] But it's about spending money the right way and finding the right balance for the team." Ferguson refused to be drawn on comments from Carlos Tevez that he is unhappy at United's stalling over contract talks. Tevez's public expression of frustration has reportedly infuriated the United boss but he was tight-lipped on Friday, insisting: "I'm not going to comment on players' contracts. It's a private matter between the player and the club."

    Reply
  • Wat is er zo goed over hoofdtelefoon

    Posted by mrswanzi on 06/05/2013 08:34pm

    [url=http://koptelefoon-monsterbeats.blogspot.com/]beats by dre[/url] Beats By Dre is domineert de hoofdtelefoon game al een tijdje, nu lijkt het alsof ze uit breidt naar de home audio markt met de introductie van de ¡®pil. ¡°De pil is een draagbare, draadloze luidspreker met een fantastisch geluid, net als de beats koptelefoon. Het beschikt over Bluetooth-mogelijkheden voor aansluitingen van maximaal 30 meter met een apparaat. Het beschikt ook over een interne microfoon die conference calls mogelijk maken. [url=http://koptelefoon-monsterbeats.manifo.com/]Beats by dre Goedkope[/url] Wanneer je echter muziek wil luisteren via een audiodrager zonder Bluetooth sluit je probleemloos alsnog een kabel aan. Via USB laat je de Beats by Dr. Dre Wireless in korte tijd weer op voor 10 uur luisterplezier. Geniet volledig in stijl en draadloos van je favoriete muziek met de Beats by Dr. Dre Wireless.De Beats Wireless levert net als alle andere Beats By Dr. Dre producten glasheldere hoge tonen, een natuurlijk middengebied en een krachtige strakke bas. Om ook via bluetooth de beste prestaties te kunnen leveren is de Beats Wireless voorzien van de laatste bluetooth technologien en geschikt voor ontvangst van AAC en APT-X signalen. Uiteraard is ook deze Beats voorzien van ControlTalk. [url=http://koptelefoon-monsterbeats.webs.com/]beats by dre[/url] Om de fraaie hoofdtelefoon in topconditie te houden krijgt de gebruiker er ook een zacht poetsdoekje en een stevige beschermcase bij. En tenslotte wordt er ook een set AAA-batterijen meegeleverd voor direct luisterplezier. De Studio-hoofdtelefoons maken gebruik van noise canceling, waardoor omgevingsrumoer onderdrukt wordt. Alle modellen worden zeer compleet geleverd met twee kabels. Hiervan is er een voorzien van een gentegreerde microfoon en bedieningstoetsen voor gebruik met iOS-apparaten.

    Reply
  • clarisonic pro with the cadaver whisk is sterling for me

    Posted by iouwanzi on 06/05/2013 08:34pm

    [url=http://www.miaclarisonicaustralia.org/]clarisonic mia online[/url] Hvis du interesserer lyden, hvordan man kan lytte til din musik, så vil du elske deBeats by Dr. Dre solo højtydende hovedtelefoner. Uanset om du er fagfolk eller entusiaster, de er den perfekte høj kvalitet at lytte til dig igen, hvis du interesserer lyd, hvordan du kan lytte til din musik på farten, så vil du elske beat af Dr. Dre Solo high-performance hovedtelefoner. Uanset om du er fagfolk eller entusiaster, de er perfekte, høj kvalitet lytter til dig på vejen. [url=http://www.miaclarisonicaustralia.org/clarisonic-classic]clarisonic classic[/url] Fordelene og ulemperne ved de forskellige typer af hovedtelefonerHeadset hovedtelefoner, takket være en større enhed, lydkvaliteten er mere bedre, men på grund af nogle store volumen, ikke er nem at bære. Ørepropper lille enhed design, kompakt og let at bære, velegnet til udendørs brug. Ørekrog øretelefon typen headset med ørepropper i mellem et smukt udseende, komfortable at bære, lyde bedre egenskaber end ørepropper ulempe er følsom over for støj udefra, som er egnet til at bære i foråret, og denne sæson . Forskellige typer hovedtelefoner er anderledes, for at se om du ønsker at bruge under hvilke omstændigheder. [url=http://www.australiaclarisonic.com/clarisonic-pro]clarisonic pro[/url] BIII booo din troede involverer let jazz, med essentials involverer normal, god ole ‘, sammen med digitalkameraer sange for dig at lave en ny specifikt eksklusiv lyd. BIII øjeblikket omdefinerer private musik ekspertise til at gøre dine musikernes øretelefoner. Enhver observere, hver eneste nuance, kan optaget med aldrig-hørt-før realistisk look, plus iøjnefaldende design og stil trådløse høretelefoner bestemt ved en ny trompet mundstykke har som en installation vidnesbyrd om den mestre kunsten. Disse former for sædvanligvis er ikke kun de bedste ørepuder vedrørende jazz. Uanset hvad nogen hører, vil BIII sikkert vokset til betragtes som en af dine nuværende all-time musikalske teknologi højder.

    Reply
  • It's been a rechannel week in role of comportment undistinguished retailer|egg on assuagement online

    Posted by SosseRourreli on 06/03/2013 04:27am

    The Best Laid Plans ELLE The Best Laid PlansMarch 26 12:02 PMby ELLE 0 Comments laughing hysterically at god-knows-what in my unplanned for red dress So I planned on wearing this little vintage gold backless minidress on my birthday forever. Or, you know, for the past couple of weeks. [url=http://savebigshopping.com/]http://savebigshopping.com/[/url] Which is a pretty long time to plan on wearing something. Anyway, as I was getting ready to meet my friends for dinner on Saturday night, I pulled it on over my head, looked in the mirror....and realized that it was all wrong. Way too glittery and gold for a dinner [url=http://savebigshopping.com/]coach factory[/url] and some East Village bar-hopping. So after a few panicked moments during which the entire contents of both of my closets ended up on my bedroom floor, I [url=http://savebigshopping.com/]http://savebigshopping.com/[/url] settled on a tomato-red v-neck dress that I've had for years. Kind of a let-down but it just goes to show how even the simplest of plans can go totally awry. And then there are the bigger categories of [url=http://savebigshopping.com/]coach outlet[/url] plans. Like [url=http://savebigshopping.com/]coach factory[/url] the ones we make on New Year's Eve when we sit down and plan out who we're going to be in the next year, how we're going to be better, what we're going to do and when. Or for me, that always happens on birthdays. Another year older just seems more urgent to me than a new calendar year. So instead of New Year's resolutions, I make birthday resolutions. I come up with a game plan for what I'm going to accomplish in the year's time before I'm yet ANOTHER year older. My mental checklist of goals this year went something like this: Finish novel ASAP. Stop dating ridiculously inappropriate [url=http://savebigshopping.com/]coach factory[/url] men. Stop dating ridiculously unavailable men. Stop smoking socially. Run five miles a day and eat less. Or at least eat healthier. So, okay, I broke two out of five about, oh, three hours into my birthday but I, um....did my best....? ANYway, I'm fully aware that most of these things are probably going to take a little more time and growing up than a year can provide but I just can't help making my little lists. I'm sure we all have a plan, a mental checklist that will comprise our perfect lives. But I'm also sure that no matter how diligently we design and classify and organize, it's pretty futile. Because we can strategize all we want, but when it comes down to it, they're just blueprints that don't take into account the unexpected. The unforeseen things, people, and events that can derail even the best laid plans. But we do the best we can. And in the end, that's all anyone can do. And besides, sometimes, those unexpected things, those blindsiding moments that you never see coming–sometimes those are exactly the ones that are really worth living for.

    Reply
  • lululemon buying|lululemon canada how to be in the defeat ascendancy — don’t i long for to detritus here and castigate you that

    Posted by LecyLayelry on 06/03/2013 01:01am

    LeBron James' Yoga

    Reply
  • wholesale jerseys from china

    Posted by Adarotupirrit on 05/06/2013 03:06pm

    NFL coaches and teams usually are mandating cost regarding time of year NFL lottery tickets. You will find very little sports adventures getting trialled now. Thus in theory enthusiasts haven't so much shed anything. Nevertheless using the NFLPA decertifying [url=http://wholesaleauthenticjerseysus.weebly.com/]wholesale authentic jerseys[/url] as a union and the owners now in court, facing potential antitrust violations, it's safe to assume that the April 28-30 draft and free agency will be affected in some way.Cheap Texas Longhorns -Jerseys are actually snowed under utilizing autograph demands.With fans going crazy over the National Football Teams of Texas Longhorns, the Texas Longhorns jerseys are in high [url=http://wholesaleauthenticjerseysus.weebly.com/]http://wholesaleauthenticjerseysus.weebly.com/[/url] demand everywhere. We sale high quality, Fans wear design jerseys online as a statement about which team they root for, and often get their favorite player's name on the back. Exactly what will probably end in losing the actual 2011 time of year? The leading situation with CBA talks features, and definately will possibly be, the actual fraction of NFL income to help battler incomes. Different big considerations comprise NFL [url=http://wholesaleauthenticnflt-shirts.webs.com/]wholesale authentic nfl T-Shirts [/url] rookie salaries and the legal inability of franchises to recoup signing bonuses from players who breach contracts or refuse to perform, NFL Game day live. In such contentious negotiations, it [url=http://wholesaleauthenticnflt-shirts.webs.com/]http://wholesaleauthenticnflt-shirts.webs.com/[/url] is very difficult, and sometimes impossible, to determine which side has a better case.As professional sports activities player fans, usually you will buy some purchase NFL authentic jerseys at wholesale prices, even use it within the exact same color selection, style because you're chosen NFL team.

    Reply
  • authentic nhl jerseys,thailand russia jersey

    Posted by enarvenow on 05/06/2013 12:19pm

    Messi once again saving the Barcelona micro-blog, they made it simpler for Barcelona triumph by simply scoring a couple of goals, and minimize the Barcelona attributable to the Winners Little league will be ill at ease outside frustration. The match up against Bettis, Barcelona stayed inadequate. Prior to the Messi play intended for Barcelona, Jesse Villa is going to be flattened the fico score only two -- only two, as well as the Argentina superstar along with his undisputed level, assist Barcelona secured the triumph. Juventus sits inside thirty-fifth Serie The League's 1-0 triumph on the Palermo, still left from the Little league three ahead of a couple of match up Key west 14 factors, ahead of defending achievements. [url=http://shirts-jerseys.bravesites.com/]cheap soccer shirts[/url] Prior to the referee blew the whistle, Juventus discipline Conti perhaps a bit stressed, continued the sidelines complain the reason why the referee failed to whack the whistle, needless to say the distance therefore in close proximity to Juventus discipline trophy, the spirits will be easy to understand, thinking that the seem implies that if you Wen ended up being ahead of defending the whistle blew, the main the judge right away converted into the seashore connected with enjoyment. The holders connected with Juventus devotees in addition played a large photo undoubtedly geared up 31 caps, the middle stadium in addition taken care of the endorsed team get ready to the substantial 31 crown great, devotees will be poured to the stadium while using workforce to be able to celebrate the name, Juventus online players could be to turn out to be the concentrate, base along with Lini, than alternative Juventus online players have 31 crown commemorative greeting card carnival, Captain Buffon in addition put on 31 crown commemorative T-shirt, devotees along with personnel include hurried onward to be able to larg along with kiss along with Buffon, at this point the stadium has been Carnival devotees "occupied", [url=http://shirts-jerseys.bravesites.com/]cheap soccer jerseys[/url] content we were holding keeping a variety of commemorative banners, the scene to be able to celebrate snap shots, keep for a long time aggregation not necessarily inside the center of the judge, as well as the persons from the holders is usually without any move forward through leaving behind, celebrate a further triumph. On the other hand, Juventus online players but not an excessive amount of to remain on the review, yet they're just from the locker space began his carnival, wine wanton spray shower space into madness, Juventus online players perhaps wearing shorts bare-skinned torso into battle, perhaps Conti ingest. After that from the locker space, Juve and will discipline Kong Diba simply briefs, along with put that, specifically to the swimming pool.

    Reply
  • wholesale jerseys from china

    Posted by alterrext on 05/04/2013 06:25am

    At wholesale prices NFL jerseys offer the danger in making some sort of contrast regarding jerseys. All of us just review identical basketball jerseys cost. Enough sites possibly be addicted to getting contrast at numerous [url=http://wholesaleauthenticjerseysus.weebly.com/]wholesale jerseys cheap[/url] goods and services, however it is actually easy to make errors. On the contrary, this unusual website be absorbed in owning unity that is World Cup wholesale jerseys. You not only can require related messages on the accessible retailers that supply with the jerseys, but also be able to show difference of the price and carriage chooses. The visitors are available [url=http://wholesaleauthenticjerseysus.weebly.com/]http://wholesaleauthenticjerseysus.weebly.com/[/url] to get the most excellent cost for all special article through comparing the entire probable selectionsin a nearby position, rather than by seeking a range of websites. Like this, you save both time and money a lot. It is so helpful for each client. Related to the development of nfl jerseys with China, China financial system features getting escalating speedily as well as China turn as a appreciable probable industry coming from 1980. Whichever a product or even some sort of preparing [url=http://wholesaleauthenticnflt-shirts.webs.com/]wholesale authentic nfl T-Shirts [/url], an even the space industry, Made In China can be found here and there. China ,which is the heart of a number of products and much cut-throat competition, constantly benefit people of ppurchasing from it.In the past 30 years, Chinese economy is on the increase at the top of speed. China is the third largest in economy, while the U.S. and Japan on 1st [url=http://wholesaleauthenticnflt-shirts.webs.com/]http://wholesaleauthenticnflt-shirts.webs.com/[/url] and 2nd correspondingly. Together with the boosting economy, China is the major trading nation and exporter of products in the globle at present. Thus, lots of people are interested in trading in China.

    Reply
  • More concessions with herveleger, more take napping!

    Posted by tradecomewcp on 03/24/2013 01:56pm

    cheap herve leger dress white herve leger dress herve leger replica dresses replica herve leger dress herve leger stores herve leger outlet herve leger cheap iphone 4s on sale iphone 4g for sale iphones on sale

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • The explosion in mobile devices and applications has generated a great deal of interest in APIs. Today's businesses are under increased pressure to make it easy to build apps, supply tools to help developers work more quickly, and deploy operational analytics so they can track users, developers, application performance, and more. Apigee Edge provides comprehensive API delivery tools and both operational and business-level analytics in an integrated platform. It is available as on-premise software or through …

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds