<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CD-Rom Laufwerke auswerfen]]></title><description><![CDATA[<p>Hallo...<br />
Ich will mir grade eine Sammlung von API Calls unter Windows schreiben, die ich per JNI unter Java nutzen kann.<br />
Dabei meckert aber hier schon der Borland Compiler. Ich weiß aber absolut nicht warum!</p>
<pre><code>#include &lt;jni.h&gt;
#include &lt;windows.h&gt;
#include &quot;win.h&quot;

void openclosecd (char szDrive[], bool open)
{
	MCI_OPEN_PARMS   op;
	MCI_STATUS_PARMS sp;
	DWORD dwFlags;

	ZeroMemory(&amp;op, sizeof(MCI_OPEN_PARMS));
	op.lpstrDeviceType  = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
	op.lpstrElementName = szDrive;

	dwFlags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE;

	if(!mciSendCommand(0, MCI_OPEN, dwFlags, (unsigned long)&amp;op))
	{
		sp.dwItem = MCI_STATUS_READY;

		if(open)
			mciSendCommand(op.wDeviceID,MCI_SET,MCI_SET_DOOR_OPEN, 0);
		else
			mciSendCommand(op.wDeviceID,MCI_SET,MCI_SET_DOOR_CLOSED, 0);

		mciSendCommand(op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0);
	}
}

JNIEXPORT void JNICALL Java_WinAPI_opencd (JNIEnv *env, jobject obj)
{
	for(int i = 0; i &lt; 26; i++)
		if(GetDriveType((i + 'A') + &quot;://&quot;) == DRIVE_CDROM)
			openclosecd((i + 'A') + &quot;://&quot;, true);
}

JNIEXPORT void JNICALL Java_WinAPI_closecd (JNIEnv *env, jobject obj)
{
	for(int i = 0; i &lt; 26; i++)
		if(GetDriveType((i + 'A') + &quot;://&quot;) == DRIVE_CDROM)
			openclosecd((i + 'A') + &quot;://&quot;, false);
}
</code></pre>
<p>Er sagt mir immer<br />
Fehler E2303 win.c 5: Typname erwartet</p>
<p>Aber ich kenn die Deklaration von Funktionen unter C nur so, wie oben angegeben...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/151049/cd-rom-laufwerke-auswerfen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 21 Jul 2026 20:23:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/151049.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 22 Jun 2006 16:02:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:02:03 GMT]]></title><description><![CDATA[<p>Hallo...<br />
Ich will mir grade eine Sammlung von API Calls unter Windows schreiben, die ich per JNI unter Java nutzen kann.<br />
Dabei meckert aber hier schon der Borland Compiler. Ich weiß aber absolut nicht warum!</p>
<pre><code>#include &lt;jni.h&gt;
#include &lt;windows.h&gt;
#include &quot;win.h&quot;

void openclosecd (char szDrive[], bool open)
{
	MCI_OPEN_PARMS   op;
	MCI_STATUS_PARMS sp;
	DWORD dwFlags;

	ZeroMemory(&amp;op, sizeof(MCI_OPEN_PARMS));
	op.lpstrDeviceType  = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
	op.lpstrElementName = szDrive;

	dwFlags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE;

	if(!mciSendCommand(0, MCI_OPEN, dwFlags, (unsigned long)&amp;op))
	{
		sp.dwItem = MCI_STATUS_READY;

		if(open)
			mciSendCommand(op.wDeviceID,MCI_SET,MCI_SET_DOOR_OPEN, 0);
		else
			mciSendCommand(op.wDeviceID,MCI_SET,MCI_SET_DOOR_CLOSED, 0);

		mciSendCommand(op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0);
	}
}

JNIEXPORT void JNICALL Java_WinAPI_opencd (JNIEnv *env, jobject obj)
{
	for(int i = 0; i &lt; 26; i++)
		if(GetDriveType((i + 'A') + &quot;://&quot;) == DRIVE_CDROM)
			openclosecd((i + 'A') + &quot;://&quot;, true);
}

JNIEXPORT void JNICALL Java_WinAPI_closecd (JNIEnv *env, jobject obj)
{
	for(int i = 0; i &lt; 26; i++)
		if(GetDriveType((i + 'A') + &quot;://&quot;) == DRIVE_CDROM)
			openclosecd((i + 'A') + &quot;://&quot;, false);
}
</code></pre>
<p>Er sagt mir immer<br />
Fehler E2303 win.c 5: Typname erwartet</p>
<p>Aber ich kenn die Deklaration von Funktionen unter C nur so, wie oben angegeben...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083148</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083148</guid><dc:creator><![CDATA[Andy1988]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:02:03 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:09:23 GMT]]></title><description><![CDATA[<p>Was ist win.h? Probier mal BOOL statt bool</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083165</guid><dc:creator><![CDATA[ddfdf]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:09:23 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:16:14 GMT]]></title><description><![CDATA[<p>ddfdf schrieb:</p>
<blockquote>
<p>Was ist win.h? Probier mal BOOL statt bool</p>
</blockquote>
<p>Der Unterschied zwischen BOOL (int) und bool (bool) sollte hier eingelt. nicht relevant sein... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083176</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083176</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:16:14 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:18:01 GMT]]></title><description><![CDATA[<p>Hi CodeFinder</p>
<p>also im informatik unterricht haben wir gelernt dass bool nur 4 bits hat während BOOL 8 bits hat. Mein Info Lehrer meint dass viele Kompiler damit Probleme haben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083180</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083180</guid><dc:creator><![CDATA[ddfd]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:18:01 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:23:38 GMT]]></title><description><![CDATA[<p>Wenn du uns auch noch sagst, auf welche Zeile im Code sich der Fehler bezieht, müssen wir nicht mehr rätseln.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083187</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:23:38 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:28:30 GMT]]></title><description><![CDATA[<p>Hoi,<br />
Wie gesagt...BOOL ist als int(eger) definiert...<br />
sizeof(int) = 4 Bytes<br />
sizeof(bool) = 1 Bytes<br />
...Unter MV C++ 6.0</p>
<p>ddfd schrieb:</p>
<blockquote>
<p>also im informatik unterricht haben wir gelernt dass bool nur 4 bits hat während BOOL 8 bits hat.</p>
</blockquote>
<p>Da ein Byte aus 8 Bits besteht hat demnach:</p>
<p>BOOL: 4 * 8 Bits = 32 Bits<br />
bool: 1 * 8 Bits = 8 Bits</p>
<p>Aber warum sollte ein Compiler deshalb Probleme haben ?</p>
<p>PS: Int kann auf manchem Compilern jedoch auch nur 2 Bytes belegen...sollte aber dennoch kein problem darstellen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083194</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:28:30 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:29:32 GMT]]></title><description><![CDATA[<p>WebFritzi schrieb:</p>
<blockquote>
<p>Wenn du uns auch noch sagst, auf welche Zeile im Code sich der Fehler bezieht, müssen wir nicht mehr rätseln.</p>
</blockquote>
<p>Sinnvoll ...^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083195</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083195</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:29:32 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:33:15 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Also in der win.h steht nur der automatisch erzeugte Code von dem programm javah, was mir aus ner Klasse die nativen methodenaufrufe raussucht und die Funktionsdeklarationen dazu erzeugt:</p>
<pre><code>/* DO NOT EDIT THIS FILE - it is machine generated */
#include &lt;jni.h&gt;
/* Header for class WinAPI */

#ifndef _Included_WinAPI
#define _Included_WinAPI
#ifdef __cplusplus
extern &quot;C&quot; {
#endif
/*
 * Class:     WinAPI
 * Method:    opencd
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_WinAPI_opencd
  (JNIEnv *, jobject);

/*
 * Class:     WinAPI
 * Method:    closecd
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_WinAPI_closecd
  (JNIEnv *, jobject);

#ifdef __cplusplus
}
#endif
#endif
</code></pre>
<p>Ich muss da ja nicht noch die openclosecd-Funktion einfügen oder ist das beim borland Compiler Pflicht?<br />
Ich hab bisher nur mit dem gcc gearbeitet...</p>
<p>Der Fehler befindet sich in Zeile 5. Also direkt die erste Codezeile.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083205</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083205</guid><dc:creator><![CDATA[Andy1988]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:33:15 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:42:48 GMT]]></title><description><![CDATA[<p>Den Titel &quot;CD-Rom Laufwerke auswerfen&quot; find ich wirklich sehr gelungen. Raus mit dem alten Kram aus meinem Rechner! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083219</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083219</guid><dc:creator><![CDATA[Cool...]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:42:48 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:44:31 GMT]]></title><description><![CDATA[<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-80618.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-80618.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083220</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:44:31 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:47:54 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/5675">@JOchen</a>: Soweit ich das jetzt überblickt habe, geht es nicht darum...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083227</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083227</guid><dc:creator><![CDATA[WebFritzi]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:47:54 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Rom Laufwerke auswerfen on Thu, 22 Jun 2006 16:49:21 GMT]]></title><description><![CDATA[<p>Ich wollte trotzdem noch darauf aufmerksam machen, dass mciXxx IMHO nicht die beste Lösung ist, sondern über DeviceIoControl...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1083230</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1083230</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Thu, 22 Jun 2006 16:49:21 GMT</pubDate></item></channel></rss>