Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MCI command strings

Status
Not open for further replies.

zBuilder

MIS
May 13, 1999
159
0
0
CA
www3.bc.sympatico.ca
Below is some experimental code I wrote while trying to figure out how to control the CD-ROM drive via MCI command strings. Excuse the _InitEasyWin() I just use it as a quick and dirty way to try out ideas in Borland C++ 3.1 without writing a whole swag of code.<br>
Basically, the code is supposed to check to see if the CD door is open and if it is, close it. If the door is closed it should open when the program is run. The problem is with the line:<br>
<br>
status = mciSendString(&quot;status cdaudio mode&quot;, Buffer, 255, NULL);<br>
<br>
It always says the tray is open if it is empty (No CD).<br>
If there is a CD in the tray, then the program acts as intended. Is there a way around this? ie: tell if the tray is opened/closed with no CD in the tray?<br>
Full code follows:<br>
<br>
#include &lt;windows.h&gt;<br>
#include &lt;mmsystem.h&gt;<br>
#include &lt;stdio.h&gt;<br>
#include &lt;string.h&gt;<br>
<br>
void main()<br>
{<br>
DWORD status;<br>
char Buffer[256] = &quot;not ready&quot;;<br>
<br>
_InitEasyWin();<br>
status = mciSendString(&quot;open cdaudio&quot;, NULL, 0, NULL);<br>
if (status != 0)<br>
{<br>
printf( &quot;error!&quot; );<br>
}<br>
<br>
<br>
status = mciSendString(&quot;status cdaudio mode&quot;, Buffer, 255, NULL);<br>
if (status != 0)<br>
{<br>
printf( &quot;error! 1&quot; );<br>
}<br>
printf(&quot;--&gt;%s&lt;--&quot;, Buffer);<br>
<br>
if ( strcmp( &quot;open&quot;, Buffer ) == 0)<br>
{<br>
status = mciSendString(&quot;set cdaudio door closed&quot;, NULL, 0, NULL);<br>
if (status != 0)<br>
{<br>
printf( &quot;error!&quot; );<br>
}<br>
}<br>
else<br>
{<br>
status = mciSendString(&quot;set cdaudio door open&quot;, NULL, 0, NULL);<br>
if (status != 0)<br>
{<br>
printf( &quot;error!&quot; );<br>
}<br>
}<br>
<br>
<br>
mciSendString(&quot;close cdaudio&quot;, NULL, 0, NULL);<br>
}<br>
<p> <br><a href=mailto:Kim_Christensen@telus.net>Kim_Christensen@telus.net</a><br><a href= Page</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top