Important alert: (current site time 7/16/2013 1:40:40 AM EDT)
 

VB icon

A ALL CD-tray opener !!!!! and CD-RW and DVD-RW :)

Email
Submitted on: 5/7/2003 5:03:57 PM
By: <_Nilz_> 
Level: Beginner
User Rating: By 1 Users
Compatibility: VB 6.0
Views: 22960
(About the author)
 
     It opens ALL CD-trays in the computer, u can also edit the source so that u can make only the CD-RW pop out or the DVD-rw ..... :)
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: AALL CD-tray opener !!!!! and CD-RW and DVD-RW :)
' Description:It opens ALL CD-trays in the computer, u can also edit the source so that u can make only the CD-RW pop out or the DVD-rw ..... :)
' By: <_Nilz_>
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=45322&lngWId=1'for details.'**************************************

'ok, here is the first code, it opens ALL cd-'trays:
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
If colCDROMs.Count >= 1 Then
For i = 0 To colCDROMs.Count - 1
colCDROMs.Item(i).Eject
Next 
End If
'
'The next code opens only the CD-rw:
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
If colCDROMs.Count >= 1 Then
For i = 0 To colCDROMs.Count - 1
colCDROMs.Item(1).Eject
Next 
End If
'
'And this one ONLY the DVD-rw:
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
If colCDROMs.Count >= 1 Then
For i = 0 To colCDROMs.Count - 1
colCDROMs.Item(2).Eject
Next 
End If
'FOR THE USE OF THE LAST TWO U NEED TO BE SURE 
'THAT THE CD-TRAY IS THERE !!!!! by a little 
'if then u can make yourself :)


Other 4 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

5/7/2003 7:42:23 PMpoop_4_brains

i dont think there is a difference in commands just because it accepts a different kind of cd
(If this comment was disrespectful, please report it.)

 
5/7/2003 8:24:56 PMpoop_4_brains

+ u need windows media player 7 for this to work
(If this comment was disrespectful, please report it.)

 
5/8/2003 5:11:38 AM<_Nilz_>

What do u mean by that...I don't really understand what u mean ... :P
(If this comment was disrespectful, please report it.)

 
5/8/2003 6:24:32 PMWet_Keyboard

No option explicit, Media Player 7 minimum required, OCX required.

Conclusion = waste of PSC bandwidth
(If this comment was disrespectful, please report it.)

 
7/5/2003 9:19:29 PMKenKnutson

Hate to agree with somebody that goes by a handle such as Wet Keyboard but he/she is right. Waste of bandwidth. For those looking for a 'Real' CDROM tray application do a PSC search for "CDROM Tray" sans quotes. It's something I wrote as a compilation of several pieces of code available on PSC. Enjoy.
(If this comment was disrespectful, please report it.)

 
3/27/2006 10:54:10 PMKai Andre Koenig

'This Routine better On Original SOURCE
'The Drives Open and Close without Pause
'You have no Time to Put CD in!

'1 = SLAVEDEVICE
'0 = MASTERDEVICE
Set oWMP = CreateObjec("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection
If colCDROMs.Count >= 1 Then
For i = 1 To 1
colCDROMs.Item(1).Eject
Next
End If



(If this comment was disrespectful, please report it.)

 
5/11/2006 3:30:25 AMsemi

Erm... First of all, the For...Next loop in the second and third bit of code is pointless as you didn't use the loop variable inside the code but instead just specify the drive number, e.g.:

colCDROMs.Item(1).Eject
...
colCDROMs.Item(2).Eject

You could simply remove the For lines before and the Next lines after these lines and it would still have the same effect.

Second, what if somebody hasn't got the default setup of one CD and one CD-R drive on his/her computer? As you didn't really search for CD-R devices but just specified an index, this won't work for them.

Third, there should be a better solution than instancing a Windows Media Player object to do this, as it won't work / crash on everyone that does not have Windows Media Player installed.

This is the solution i would propose (can't detect whether or not it's a CD-R drive though):
http://www.semicolonsoftware.de/OpenCloseCD.zip

(If this comment was disrespectful, please report it.)

 
5/11/2006 5:57:55 AM<_Nilz_>

stop giving feedback, can't you see it's allmost 3 years old ? .. gees I haven't written a code in like 2 years ..
(If this comment was disrespectful, please report it.)

 
1/15/2008 5:54:37 PMhumphrey

this is great thanx
(If this comment was disrespectful, please report it.)

 
4/19/2011 9:50:15 AMsammie

am trying it now.am a student in kenya.in a college
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.