Results 1 to 5 of 5

Thread: [2005] CD/DVD Eject using WMI

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    40

    Exclamation [2005] CD/DVD Eject using WMI

    well, I am looking for the code to eject CD using WMI class. May be System.Management can do this but as I am extremely new to .NET I need ur help.

    I have used mciSendMessage but it's giving me the error. However, I prefer to use System.Management namespace if it can possible thurgh it..

    I am Using .NET 2005 ..

    bye

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] CD/DVD Eject using WMI

    I use this when I want to eject the disc tray:
    VB Code:
    1. Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
    2.       (ByVal lpstrCommand As String, _
    3.       ByVal lpstrReturnString As String, _
    4.       ByVal uReturnLength As Int32, _
    5.       ByVal hwndCallback As Int32) As Int32
    6.  
    7.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    8.         mciSendString("set CDAudio door open", Nothing, 127, 0)
    9.     End Sub

    not wmi but hey it works
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    40

    Re: [2005] CD/DVD Eject using WMI

    Well It's working fine compare to my previous code..

    VB Code:
    1. mciSendString("set CDAudio door open", 0, 0, 0)

    btw, can u plz add comment so that i can understand the function..

    Moreover, I have also found one link which seems to use WMI but i can't understand the code..

    http://www.mredkj.com/netconversions/cdevents.html

    If some one can explain it to me than it would be great..

  4. #4
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    297

    Re: [2005] CD/DVD Eject using WMI

    The link is to detect when the tray has been ejected or loaded (propbably by detecting when media arrives.)

    gigemboy shows how to eject a specific drive with mciSendString here:
    http://www.vbforums.com/showthread.p...ighlight=eject
    here's load/unload/lock/unlock by various methods:
    http://www.vbforums.com/showthread.php?t=357496

    Use MciSendstring, there is no method to eject using WMI.
    Look up MCI in the msdn library...

  5. #5
    Hyperactive Member Coool's Avatar
    Join Date
    Feb 2006
    Location
    System.Coool
    Posts
    333

    Re: [2005] CD/DVD Eject using WMI

    GREAT dude. I am just looking for this ..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width