|
-
Sep 30th, 2003, 05:09 AM
#1
Thread Starter
Frenzied Member
Detect if CD door opens
How can I detect if the CD door opens while my app is running? I am makig something for my son, but I want the app to die if he opens the CD door. That way when he puts the next CD in, it will play the next app, and I don't have to worry about him getting confussed.
-
Sep 30th, 2003, 07:49 AM
#2
Fanatic Member
This opens the cddoor via a button but you can implement the code wherever suits you.
Hope this helps.
VB Code:
Private Sub Command1_Click()
retvalue = mciSendString("set CDAudio door open", _
returnstring, 127, 0)
MsgBox ("The Cddoor has opened,Your application will terminate"), vbInformation
-
Oct 1st, 2003, 03:02 AM
#3
Thread Starter
Frenzied Member
No, I don't need to open the door, I need to know if the door has been opened. I need to know if he pushed the eject button on the CD drive, then kill the app.
-
Oct 1st, 2003, 06:20 PM
#4
-
Oct 1st, 2003, 06:22 PM
#5
-
Oct 1st, 2003, 11:12 PM
#6
Thread Starter
Frenzied Member
Ok, I downloaded the cdspy project, but am a little lost at what I am looking at. Do you think you can walk me through it. When I run it nothing happens, should it? I see the Function ProcessDeviceChange that looks like it will tell if a cd is inserted or removed, but I am not sure what to pass it. Thanks.
-
Oct 2nd, 2003, 01:36 AM
#7
Frenzied Member
Strange how much my coding on that post looks like what you posted, manavo.
-
Oct 5th, 2003, 04:20 PM
#8
-
Oct 5th, 2003, 04:30 PM
#9
-
Oct 6th, 2003, 12:49 AM
#10
Thread Starter
Frenzied Member
ah, ok i see now. But, here is what I am doing. I have an application burnt to a CD. This application allows my son to choose from the movies (also bunt to the CD) and open them with the default player for the file type, ie .avi opens with Windows Media Player. He has enough movies to fit about 8 CDs. When he puts one it, it runs my application (burnt on the CD) and allows him to navigate and play the movies on the CD. What I want is after he puts a CD in and it runs my application, that if he decides that is not the CD he wants, and opens the CD tray, that the application will terminate. This way when he puts in another CD, the application on it will run and he wont accidentally use the old app from the CD that is no longer in the drive.
-
Oct 6th, 2003, 09:02 AM
#11
-
Oct 6th, 2003, 10:55 AM
#12
Frenzied Member
If I was doing this project, I'd check at startup to see if my app was already running. You could use FindWindow to look for your application (I'm not sure about PrevInstance).
If it was already running, you could just unload.
-
Oct 6th, 2003, 10:05 PM
#13
Thread Starter
Frenzied Member
manavo11, I think that will work, thanks I'll try that.
Shawn N, that would be easiest, but I don't think it will do what I need because, if he ejects the CD and dosent put a new one in, the app will stay running. Then if he tries to open one of the movies it will error out because the path won't exist anymore.
-
Oct 6th, 2003, 10:10 PM
#14
Frenzied Member
Nothing a little error handling couldn't handle.
-
Oct 7th, 2003, 05:22 AM
#15
Thread Starter
Frenzied Member
Yeah, I hear you, but I can't very well popup a message to him because he can't read. I think it would be less confusing in the long run to lhave the app go away. He can understand that you put the CD in, play movies, and remove the CD. Oh, and my 2 year old is using these now too.
-
Oct 7th, 2003, 11:38 AM
#16
Frenzied Member
Yea, I was thinking about that right after my post.
-
Oct 8th, 2003, 09:20 AM
#17
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|