January 25th, 2000, 06:45 AM
How can I open a CD-Rom device by software ?
Thanks for help !
Michael
Thanks for help !
Michael
|
Click to See Complete Forum and Search --> : Open CD-Rom January 25th, 2000, 06:45 AM How can I open a CD-Rom device by software ? Thanks for help ! Michael Chris Eastwood January 25th, 2000, 07:53 AM Try the following code in a module / form / class / etc... ' ' Change public to private as appropriate ' private Declare Function mciSendString Lib "winmm.dll" _ Alias "mciSendStringA" _ (byval lpstrCommand as string, _ byval lpstrReturnString as string, _ byval uReturnLength as Long, _ byval hwndCallback as Long) as Long ' public Sub EjectCD() Call mciSendString("set CDAudio Door Open Wait", 0&, 0&, 0&) End Sub ' public Sub CloseCD() Call mciSendString("set CDAudio Door Close Wait", 0&, 0&, 0&) End Sub - I don't have a CD on this machine here, but it used to work fine. Chris Eastwood CodeGuru - the website for developers http://codeguru.developer.com/vb Johnny101 January 26th, 2000, 03:21 PM This is good code, but I couldn't it to close the Cd tray. it opened just fine. I'm running NT 4 workstation, any suggestions. John John Pirkey MCSD www.ShallowWaterSystems.com jhemphill January 26th, 2000, 05:51 PM ' ' Change public to private as appropriate ' Private Declare Function mciSendString Lib "winmm.dll" _ Alias "mciSendStringA" _ (ByVal lpstrCommand As String, _ ByVal lpstrReturnString As String, _ ByVal uReturnLength As Long, _ ByVal hwndCallback As Long) As Long ' Public Sub EjectCD() Call mciSendString("set CDAudio Door Open", 0&, 0&, 0&) End Sub ' Public Sub CloseCD() Call mciSendString("set cdAudio Door Closed", 0&, 0&, 1&) End Sub You'll notice, all I did was take out the waits ( It will probably work with them in though) and changed the last parameter from 0& to 1&, Presto! closing cdrom door! jhemphill January 26th, 2000, 05:57 PM I'm an idiot!!! In Chris Eastwoods example everything was exactly correct, except, his close string was "set CDAudio Door Close Wait" it should have been "set CDAudio Door Closed Wait" That is the only change that needs to be made, no 0's to 1's or none of that crap. I'm just an idiot! ......(walks off mumbling shaking head) :-) Johnny101 January 26th, 2000, 06:09 PM Thank you! That was it, add the "d" to "close". John John Pirkey MCSD www.ShallowWaterSystems.com codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |