Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. eject the cdrom

eject the cdrom

Scheduled Pinned Locked Moved The Lounge
c++comhelp
4 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hforbess
    wrote on last edited by
    #1

    Hi, I wouldnt normally ask this but I am trying to make a little joke program for my friend who is graduating. I have seen this before but dont know the source and he is graduating soon. Basically, a window would pop up when the prog was executed and say somehting like "for your graduation present... blah, blah you recieve this university cup holder" Then you click ok and the cdrom opens.... hehe....I think its funny.. Can anybody help me out.. .Like I said I normally wouldnt ask but im pressed for time and dont know if I can figure it out in time. im a newbie to MFC... thanks! harry at forbess.com;) harry

    J D 3 Replies Last reply
    0
    • H hforbess

      Hi, I wouldnt normally ask this but I am trying to make a little joke program for my friend who is graduating. I have seen this before but dont know the source and he is graduating soon. Basically, a window would pop up when the prog was executed and say somehting like "for your graduation present... blah, blah you recieve this university cup holder" Then you click ok and the cdrom opens.... hehe....I think its funny.. Can anybody help me out.. .Like I said I normally wouldnt ask but im pressed for time and dont know if I can figure it out in time. im a newbie to MFC... thanks! harry at forbess.com;) harry

      J Offline
      J Offline
      Jon Sagara
      wrote on last edited by
      #2

      Post your question in the Visual C++ forum. This is our place to get away from coding for a bit. :) Jon Sagara "Ninety percent of baseball is mental, the other half is physical." -- Yogi Bera

      1 Reply Last reply
      0
      • H hforbess

        Hi, I wouldnt normally ask this but I am trying to make a little joke program for my friend who is graduating. I have seen this before but dont know the source and he is graduating soon. Basically, a window would pop up when the prog was executed and say somehting like "for your graduation present... blah, blah you recieve this university cup holder" Then you click ok and the cdrom opens.... hehe....I think its funny.. Can anybody help me out.. .Like I said I normally wouldnt ask but im pressed for time and dont know if I can figure it out in time. im a newbie to MFC... thanks! harry at forbess.com;) harry

        J Offline
        J Offline
        Jon Sagara
        wrote on last edited by
        #3

        Forbess Enterprises Corporate Army Takes Wathefukistan :laugh: Jon Sagara "Ninety percent of baseball is mental, the other half is physical." -- Yogi Bera

        1 Reply Last reply
        0
        • H hforbess

          Hi, I wouldnt normally ask this but I am trying to make a little joke program for my friend who is graduating. I have seen this before but dont know the source and he is graduating soon. Basically, a window would pop up when the prog was executed and say somehting like "for your graduation present... blah, blah you recieve this university cup holder" Then you click ok and the cdrom opens.... hehe....I think its funny.. Can anybody help me out.. .Like I said I normally wouldnt ask but im pressed for time and dont know if I can figure it out in time. im a newbie to MFC... thanks! harry at forbess.com;) harry

          D Offline
          D Offline
          David Wulff
          wrote on last edited by
          #4

          This should really be in the VC++ forum, but anyway - this works for me:-

          void OpenCDDrive(CString strDrive)
          {
          MCI_OPEN_PARMS op;
          MCI_STATUS_PARMS st;
          DWORD flags;

          TCHAR szDriveName\[4\];
          strcpy(szDriveName, \_T("$:"));
          
          ::ZeroMemory(&op, sizeof(MCI\_OPEN\_PARMS));
          op.lpstrDeviceType = (LPCSTR)MCI\_DEVTYPE\_CD\_AUDIO;
          
          // end now if we haven't specified a drive
          if (strDrive.IsEmpty())
          	return;
          
          szDriveName\[0\] = strDrive.GetBuffer(1)\[0\];
          op.lpstrElementName = szDriveName;
          flags = MCI\_OPEN\_TYPE | MCI\_OPEN\_TYPE\_ID | MCI\_OPEN\_ELEMENT |
          	MCI\_OPEN\_SHAREABLE;
          
          // send the command
          if (!mciSendCommand(0, MCI\_OPEN, flags, (unsigned long)&op)) 
          {
          	st.dwItem = MCI\_STATUS\_READY;
          
          	mciSendCommand(op.wDeviceID, MCI\_SET, MCI\_SET\_DOOR\_OPEN, 0);
          	mciSendCommand(op.wDeviceID, MCI\_CLOSE, MCI\_WAIT, 0);
          }
          

          }

          ________________ David Wulff http://www.davidwulff.co.uk "I loathe people who keep dogs. They are cowards who haven't got the guts to bite people themselves" - August Strindberg

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups