openCdDoor & closeCdDoor

Share your advanced PureBasic knowledge/code with the community.
Pille
New User
New User
Posts: 7
Joined: Thu Jul 03, 2003 11:29 pm

openCdDoor & closeCdDoor

Post by Pille »

Code updated for 5.20+

Code: Select all

;
; by Pille - 17.07.2003
;

; If you want to change the Drive you can do it like this:
; mciSendString_("Open K: Alias DriveK Type CDAudio", 0, 0, 0)
; mciSendString_("Set DriveK Door Open", 0, 0, 0)
; mciSendString_("Set DriveK Door Closed", 0, 0, 0)

Procedure openCdDoor()
	mciExecute_("Set CDaudio Door Open")
EndProcedure

Procedure closeCdDoor()
	mciExecute_("Set CDaudio Door Closed")
EndProcedure




;-----------------------------------------
; test
;
openCdDoor()     ;open Cd door
delay(2000)      ;wait 2s
closeCdDoor()    ;close Cd door

[edit]
*g* I haven't noticed that Rings already wrote something about opening&closing the Cd door... but he made it it a very funny way - check this out viewtopic.php?p=12824

[edit2]
I got a response from 'wichtel' in the german forum that it's a lot easier to do it with the build in PB function:
cd=InitCDAudio()
UseCDAudio(cd)
EjectCDAudio(1)
EjectCDAudio(0)

I could bet that someone changed my PB help while I was searching the MSDN 'cause I didn't find anything about CD handling in the manual ;)
Anden
Enthusiast
Enthusiast
Posts: 135
Joined: Mon Jul 21, 2003 7:23 am
Contact:

Post by Anden »

Well, the InitCDAudio() function would be fine, but it doesn't work as expected (at least with NT/2k/XP).

As long as the PB program is running after calling InitCDAudio(), the drives are locked for the system (that means no new media is recognized by windooze for example).

This is a very old and very annoying bug.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Anden wrote:Well, the InitCDAudio() function would be fine, but it doesn't work as expected (at least with NT/2k/XP).

As long as the PB program is running after calling InitCDAudio(), the drives are locked for the system (that means no new media is recognized by windooze for example).

This is a very old and very annoying bug.
That no other programm can use the CD-Rom, when you start InitCDAudio() isn't a bug, but i miss a ExitCDAudio()...
Post Reply