Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open and Close CD Drawer(s)

API Functions

Open and Close CD Drawer(s)

by  craigsboyd  Posted    (Edited  )
Slighthaze = [color blue]NULL[/color]

[img http://www.sweetpotatosoftware.com/ttimages/cddrive.gif]
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.

[color green]*!* Automatically open and close the default CD drawer.[/color]
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)

[color green]*!* Have more than one CD Drive? No problem.
*!* The code below will open the drives you specify[/color]
LOCAL cCDDrive1, cCDDrive2
cCDDrive1 = "H:\" [color green]&& First CD Drive[/color]
cCDDrive2 = "I:\" [color green]&& Second CD Drive[/color]
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)
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top