Open CD Drive

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
17 posts Page 1 of 2
Was this tutorial helpful ?

33%
Yes
3
33%
No
3
33%
Little
3

Total votes: 9

User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Open CD Drive
Codex
Hello

This tutorial will tell you how to open and close CD Drive with a simple code.

Ok, so under public class <form name> add this code:
Code: Select all
Private setTrayStatus As Long

    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" _
     (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
      ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
And then in your button click event or what ever you are using, add this to the click event:

Code: Select all
        'use this code to open the tray
        setTrayStatus = mciSendString("Set CDAudio Door Open", Nothing, 0, 0)

        'use this code to close the tray
        setTrayStatus = mciSendString("Set CDAudio Door Closed", Nothing, 0, 0)
My laptop doesn't close the CD Drive so i don't know if the close code works... i have to close the drive manually...

The project includes some images :D that i got from the internet
Project Download Link:
Open CD Drive.rar
Codexvid
You do not have the required permissions to view the files attached to this post.
Last edited by Codex on Fri Aug 06, 2010 1:41 pm, edited 1 time in total.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Open CD Drive
zachman61
why not upload it here?
and thanks
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Open CD Drive
Lewis
Thats a nice little tip :) Thanks for this!
Image
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Open CD Drive
Codex
@Zachman61

Sure i will upload it here, if that makes any difference.

codexvid
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Open CD Drive
zachman61
well i just get to much spyware from megaupload and sites like it
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: Open CD Drive
XTechVB
Thanks dude
You can find me on Facebook or on Skype mihai_92b
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Open CD Drive
Codex
thanks on the comments, glad u liked it.

@Zachman61 - then i will try to upload everything here.
Last edited by Codex on Sat Aug 14, 2010 3:31 pm, edited 1 time in total.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Open CD Drive
Lewis
Zachman i doubt none of our users send spyware
Image
User avatar
elitemusic99
Just Registered
Just Registered
Posts: 5
Joined: Mon Jan 10, 2011 5:04 am

Re: Open CD Drive
elitemusic99
nice code, but the closing code i think is impossible D:
User avatar
Noob.exe
Top Poster
Top Poster
Posts: 233
Joined: Wed Mar 31, 2010 6:42 pm

Re: Open CD Drive
Noob.exe
I once made that kind of program on my previous computer (win7) and both opening AND closing worked...
<3 VB & Python
17 posts Page 1 of 2
Return to “Tutorials”