INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

API Functions

Open and Close CD Drawer(s) by craigsboyd
Posted: 4 Oct 03 (Edited 18 Feb 05)

Slighthaze = NULL


Ever needed to prompt the user to put a CD in their CD-ROM drive?  Well why not give them a message and pop open the CD drawer at the same time.  With this code your users are certain to get the hint!  Cut-N-Paste the code below into a prg file and run it from within VFP.  Please note that there are two slightly different variations of the code I wrote below.  Run each of them seperately.

*!* Automatically open and close the default CD drawer.
Declare Long mciSendString in winmm as mciSendStringA string lpstrCommand, long lpstrReturnStr, Long wReturnLenLong, Long hCallBack
local intReturn, nfilehandle
=mciSendStringA( "Set CDAudio Door Open Wait", 0, 0, 0)
intReturn = messagebox("Please insert a the CD and click OK", 0, "Unable to locate CD...")
=mciSendStringA( "Set CDAudio Door Closed Wait", 0, 0, 0)

*!* Have more than one CD Drive? No problem.
*!* The code below will open the drives you specify

LOCAL cCDDrive1, cCDDrive2
cCDDrive1 = "H:\" && First CD Drive
cCDDrive2 = "I:\" && Second CD Drive
Declare Long mciSendString in winmm as mciSendStringA string lpstrCommand, long lpstrReturnStr, Long wReturnLenLong, Long hCallBack
mciSendStringA("Open "+cCDDrive1+" type CDAudio alias CDDrawer1", 0, 0, 0)
mciSendStringA("Set CDDrawer1 Door Open Wait", 0, 0, 0)
messagebox("Insert the CD and click OK.", 0, "INSERT CD IN FIRST DRIVE")
mciSendStringA("Set CDDrawer1 Door Closed Wait", 0, 0, 0)   
mciSendStringA("Open "+cCDDrive2+" type CDAudio alias CDDrawer2", 0, 0, 0)
mciSendStringA("Set CDDrawer2 Door Open Wait", 0, 0, 0)
messagebox("Insert the CD and click OK.", 0, "INSERT CD IN SECOND DRIVE")
mciSendStringA("Set CDDrawer2 Door Closed Wait", 0, 0, 0)

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close