Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 131,633 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,297 people online right now. Registration is fast and FREE... Join Now!




CD/DVD ejection !

 
Reply to this topicStart new topic

CD/DVD ejection !

Murt2003
post 14 Oct, 2008 - 03:07 AM
Post #1


New D.I.C Head

*
Joined: 10 Oct, 2008
Posts: 2

How can I eject CD or DVD ?
I found a code to Call the process:

CODE
Call Eject_CD

But first i have to declare it and i have no idea how to do it.
Any help would be great, Thanx !

BTW i am using VB2008

This post has been edited by Murt2003: 14 Oct, 2008 - 03:19 AM
User is offlineProfile CardPM

Go to the top of the page


Re@p3rM4n
post 14 Oct, 2008 - 05:15 AM
Post #2


New D.I.C Head

*
Joined: 5 Feb, 2008
Posts: 41


My Contributions


QUOTE(Murt2003 @ 14 Oct, 2008 - 04:07 AM) *

How can I eject CD or DVD ?
I found a code to Call the process:

CODE
Call Eject_CD

But first i have to declare it and i have no idea how to do it.
Any help would be great, Thanx !

BTW i am using VB2008

try:
CODE

set wmp = createObject("wmplayer.ocx.7")
set drives = wmp.cdromCollection
sub Eject_CD()
    drives.item(0).eject()
end sub
Eject_CD()

or the like.
basically, the idea here is to create an instance of windows media player and get the available cd drives from there, and then eject the first one.
Wait, am i not allowed to give you that? I dont know, whatever.
-R@
User is offlineProfile CardPM

Go to the top of the page

jboy012000
post 16 Oct, 2008 - 04:54 AM
Post #3


New D.I.C Head

*
Joined: 7 Oct, 2008
Posts: 17

Hi,

are you wanting to be able to use a button control to eject the cd.

If this is the case you need to go to that button control in the design screen, double click it to create the click event, this will open the .vb screen, there you need to enter your code (Call Eject_CD).

This should work.

If you need a better example let me know and I will send you an example peice of code.

If it does work please reply and let me know.

Thanks

John
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 16 Oct, 2008 - 05:04 AM
Post #4


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,906



Thanked 116 times

Dream Kudos: 8450

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


Moved to VB.NET smile.gif
User is offlineProfile CardPM

Go to the top of the page

gbertoli3
post 16 Oct, 2008 - 06:03 AM
Post #5


DIC at Heart + Code

Group Icon
Joined: 23 Jun, 2008
Posts: 1,024



Thanked 16 times

Dream Kudos: 950
My Contributions


You could do it using a Win32 API Call

Make sure you add the right Imports
vb

Imports System.Runtime.InteropServices
Imports System.Text


vb

'Win32 API Call
<DllImport("winmm.dll", EntryPoint := "mciSendStringA", CharSet := CharSet.Ansi)> _
Protected Shared Function mciSendString(lpstrCommand As String, lpstrReturnString As StringBuilder, uReturnLength As Integer, hwndCallback As IntPtr) As Integer
End Function

''' <summary>
''' Opens the CD Tray.
''' </summary>
Public Shared Sub OpenCDTray()
    Dim ret As Integer = 0
    ret = mciSendString("set cdaudio door open", Nothing, 0, IntPtr.Zero)
   
End Sub


Hope this helps

This post has been edited by gbertoli3: 16 Oct, 2008 - 06:04 AM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 05:41AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month