Initialization is not the same as having the tray physically open itself.
EDIT: I forgot to include the hyperlink.
RE-EDIT: It occured to me that I could be misunderstanding a non-native english speaker in which case if you do understand what this function does and are interested in using it for that purpose I will be glad to help you further.
Ok, then you are sending the wrong arguments. First of all you are forgetting your NULL TERMINATION at the end of the string. Second it's very unlikely that the device_name given to your CD Player is CDAudio. Now that I look at it I don't even think you're passing the parameters for this command correctly.
I haven't used this command before but I'll give it a shot and post what I find in a little while.
Ok so I got rid of that particular error by EXPLICITLY linking to the winmm.lib file. My biggest gripe about MS Visual Studio is that it takes leg work like this out of the equation about %90 of the time, so when you DO run across that other %10 situation it kicks you right in the pants.
The version of winmm.lib that I linked to is in the WinDDK version 7600.16385 under
Because of one reason or another I had to change the "stprintf_s(...) command to a straight up "sprintf(...)" command but since you're using Visual C++ 2010 that shouldn't be an issue once you're all linked up. Enjoy and feel free to ask more questions if you have them.
EDIT: Spelling and such, I know there is more to edit but I don't see it right now.
RE-EDIT: By the way I'm using wxDev-C++ so the method of linking ISA different but you still have to DO the link.
If you're looping infinitely (which I don't recommend), while (true) is a little more coherent.
--------
I don't know much about the mciSendString but according to MSDN what you're doing is spamming the device with notifications & it doesn't surprise me that it's crashing. One solution would be to use the Sleep function to send the commands on some kind of interval.
wow..i see my friend doing such coding as he wanted to do the same opening cd tray by just programming but he could not find a way how to do it,..thanks for sharing some techniques and coding. i'll be recommending this site to him.
thank you :)