<?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-Laufwerk sperren]]></title><description><![CDATA[<p>Hallo,</p>
<p>gibts ne Möglichkeit, das CD-Laufwerk zu (ent)sperren, sodass es nicht aufgeht, wenn man auf den knopf drückt?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/173740/cd-laufwerk-sperren</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 19:38:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/173740.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 Feb 2007 13:18:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 13:18:34 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>gibts ne Möglichkeit, das CD-Laufwerk zu (ent)sperren, sodass es nicht aufgeht, wenn man auf den knopf drückt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231179</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231179</guid><dc:creator><![CDATA[tsp]]></dc:creator><pubDate>Mon, 19 Feb 2007 13:18:34 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 13:59:56 GMT]]></title><description><![CDATA[<p>Knipps das Kabel durch. <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>
<p>Nein im Ernst, es müsste mit einer der IO_DEVICE_CTL_Dingsbümsen gehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231220</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231220</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Mon, 19 Feb 2007 13:59:56 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 15:49:24 GMT]]></title><description><![CDATA[<blockquote>
<p>IO_DEVICE_CTL_Dingsbümsen</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> Was 'n das ? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>(Google sagte: &quot;Nichts gefunden!&quot;)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231321</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231321</guid><dc:creator><![CDATA[tsp]]></dc:creator><pubDate>Mon, 19 Feb 2007 15:49:24 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 16:12:01 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>Du brauchst <a href="http://msdn2.microsoft.com/en-us/library/aa363858.aspx" rel="nofollow">CreateFile</a> zum Ermitteln eines Handle's zu Deinem Laufwerk und <a href="http://msdn2.microsoft.com/en-us/library/aa363216.aspx" rel="nofollow">DeviceIoControl</a> zum steuern. Als Controlcode kannst Du <a href="http://msdn2.microsoft.com/en-us/library/aa363416.aspx" rel="nofollow">IOCTL_STORAGE_MEDIA_REMOVAL</a> und evtl. noch <a href="http://msdn2.microsoft.com/en-us/library/aa363405.aspx" rel="nofollow">IOCTL_STORAGE_EJECTION_CONTROL</a> verwenden.</p>
<p>Durch ein bisschen googeln hab ich das gefunden, vllt ist das n Ansatz: <a href="http://forum.vingrad.ru/index.php?act=module&amp;module=vingradfaq&amp;article=2442&amp;spider_enabled=" rel="nofollow">http://forum.vingrad.ru/index.php?act=module&amp;module=vingradfaq&amp;article=2442&amp;spider_enabled=</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231335</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 19 Feb 2007 16:12:01 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 16:48:46 GMT]]></title><description><![CDATA[<p>ich weiß nicht warum, aber auf russischen seiten gibt es alles^^</p>
<pre><code class="language-cpp">void LockDrive()
{
    HANDLE hDevice = CreateFile (&quot;\\\\.\\F:&quot;, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL);

    DWORD dwBytesReturned = 0;
    PREVENT_MEDIA_REMOVAL pmr = {true};

    DeviceIoControl (hDevice, IOCTL_STORAGE_MEDIA_REMOVAL, &amp;pmr, sizeof(pmr), NULL, 0, &amp;dwBytesReturned, NULL))

    CloseHandle (hDevice);
}

void UnlockDrive ()
{
    HANDLE hDevice = CreateFile (&quot;\\\\.\\F:&quot;, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL);

    DWORD dwBytesReturned = 0;
    PREVENT_MEDIA_REMOVAL pmr = {false};

    DeviceIoControl (hDevice, IOCTL_STORAGE_MEDIA_REMOVAL, &amp;pmr, sizeof(pmr), NULL, 0, &amp;dwBytesReturned, NULL))

    CloseHandle (hDevice);
}
</code></pre>
<p>mir war gerade langweilig, aber es funzt</p>
<p>Mfg Ominion</p>
<p>EDIT: habe das jetze noch ein bisschen optimiert, vllt. könnte man die Funktion ja noch in die FAQ zusammen mit öffnen und schließen von nem Laufwerk stellen:</p>
<pre><code class="language-cpp">bool LockDrive (char cDrive, bool bLock) 
{ 
	char lpDrive [10];
	bool bLocked = true;

	wsprintf (lpDrive, &quot;\\\\.\\%c:&quot;, cDrive);

    HANDLE hDevice = CreateFile (lpDrive, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL); 

    unsigned long dwBytesReturned = 0;
    PREVENT_MEDIA_REMOVAL pmr = {bLock}; 

    if (!DeviceIoControl (hDevice, IOCTL_STORAGE_MEDIA_REMOVAL, &amp;pmr, sizeof(pmr), NULL, 0, &amp;dwBytesReturned, NULL))
		bLocked = false;

    CloseHandle (hDevice);

	return bLocked;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1231345</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231345</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Mon, 19 Feb 2007 16:48:46 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 16:42:22 GMT]]></title><description><![CDATA[<p>Joar die Russen haben allet^^, wenn Du gestattest, bringe ein paar kleine Verbesserungen/Ergänzungen rein:</p>
<pre><code class="language-cpp">// Parameter: chDriveID &gt; Laufwerkbuchstaben, fLock &gt; true/false, lock/unlock
// Return-Wert: true &gt; Aufruf erfolgreich, false &gt; Aufruf fehlerhaft
bool ModifyDriveLock(TCHAR chDriveID, bool fLock)
{
    TCHAR szAddress[] = { TEXT('\\'), TEXT('\\'), TEXT('.'), TEXT('\\'), chDriveID, TEXT(':') };
    HANDLE hDevice = CreateFile(szAddress, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL);
    if(hDevice == INVALID_HANDLE_VALUE)
      return (false);

    DWORD dwBytesReturned = 0L;
    PREVENT_MEDIA_REMOVAL pmr = { fLock };

    bool fSuccess = static_cast&lt;bool&gt;(DeviceIoControl(hDevice, IOCTL_STORAGE_MEDIA_REMOVAL, &amp;pmr, sizeof(pmr), NULL, 0, &amp;dwBytesReturned, NULL));

    CloseHandle (hDevice);
    return (fSuccess);
}
</code></pre>
<p>EDIT: Meine ist besser :p .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231359</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231359</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 19 Feb 2007 16:42:22 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 16:55:17 GMT]]></title><description><![CDATA[<p>Den cast kannste dir sparen, wenn du das so machst wie ich, und ob unsigned long oder DWORD ist auch egal, ansonsten die Klammern beim return, is zwar nicht so schlimm, aber geht ja auch ohne und ob 0L oder 0 ist bisher auch noch egal. Ansonsten die Überprüfung ob das Handle angelegt werden konnte ist Jacke wie Hose, da das spätestens beim Versuch das zu locken bemerkt wird. So, nachdem ich kein gutes Haar mehr an deiner Version gelassen habe, muss ich noch hinzufügen, dass das mit TCHAR besser ist als mit wsprintf, da man sich nen Funktionsaufruf spart...</p>
<p>Mfg Ominion</p>
<p>EDIT: ich würde ja fast sagen unentschieden, aber wegen TCHAR haste doch gewonnen... <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/1231366</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231366</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Mon, 19 Feb 2007 16:55:17 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 17:13:05 GMT]]></title><description><![CDATA[<p>Naja, meins ist zeichensatz-unabhängig <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/1231375</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231375</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 19 Feb 2007 17:13:05 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 17:16:01 GMT]]></title><description><![CDATA[<p>Vielen Dank für die vielen Antworten.</p>
<p>Doch so richtig klappts noch nich:</p>
<p>ModigyDriveLock lockt nichts, aber bei LockDrive klappts!</p>
<p>Doch bei gar keiner Variante kann ich mein Laufwerk wieder entsperren!!!<br />
Ich krieg mein Laufwerk nicht mehr auf!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /> Helft mir!!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231378</guid><dc:creator><![CDATA[tsp]]></dc:creator><pubDate>Mon, 19 Feb 2007 17:16:01 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 17:21:27 GMT]]></title><description><![CDATA[<p>du musst bei mir bLock auf false setzen, falls du es nicht gemacht hast</p>
<p>Mfg Ominion</p>
<p>EDIT: tja CodeFinder, bei mir klappt es auch nicht...ich glaube die Medaille geht diesesmal an mich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231381</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231381</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Mon, 19 Feb 2007 17:21:27 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 17:20:15 GMT]]></title><description><![CDATA[<p>Das hab ich gemacht, aber es passiert trotzdem nichts!!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231382</guid><dc:creator><![CDATA[tsp]]></dc:creator><pubDate>Mon, 19 Feb 2007 17:20:15 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 17:24:54 GMT]]></title><description><![CDATA[<p>also haste das so gemacht:</p>
<pre><code class="language-cpp">LockDrive (&quot;F&quot;, false);
</code></pre>
<p>oder so</p>
<pre><code class="language-cpp">LockDrive ('F', false);
</code></pre>
<p>also bei mir klappt es mit der 2. Variante</p>
<p>Mfg Ominion</p>
<p>EDIT: sry war quatsch, er spuckt ja nen error beim compilieren aus, wenn du das nach 1. machst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231384</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231384</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Mon, 19 Feb 2007 17:24:54 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 18:04:21 GMT]]></title><description><![CDATA[<p>OT: ich stehe gerade total auf nem schlauch. wie kann ich ein char* in char umwandeln?= mit (char), lpChar[0], wsprintf oder cChar = lpChar[0] geht es nicht.</p>
<p>Mfg Ominion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231410</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231410</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Mon, 19 Feb 2007 18:04:21 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 18:28:15 GMT]]></title><description><![CDATA[<p>Hey Ominion,</p>
<p>deine Fkt. klappt doch, war wohl mein Fehler.<br />
Aber ich wüsste gern mal, warum die ModifyDriveLock nict funzt. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /><br />
Ich habe es getestet: Die ModifyDriveLock gibt immer <strong>false</strong> zurück. Warum?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231430</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231430</guid><dc:creator><![CDATA[tsp]]></dc:creator><pubDate>Mon, 19 Feb 2007 18:28:15 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 18:32:56 GMT]]></title><description><![CDATA[<p>Mir fällt grad noch was ein:</p>
<p>Kann man alle Laufwerksbuchstaben der CD-Laufwerke ermitteln?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231434</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231434</guid><dc:creator><![CDATA[tsp]]></dc:creator><pubDate>Mon, 19 Feb 2007 18:32:56 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 18:34:54 GMT]]></title><description><![CDATA[<p>naja, ich habe gerade in den einem topic nen link zu nem tutoril gepostet, da war das glaube ich mit drin, das war wie lerne ich richtig winapi oder so</p>
<p>Mfg Ominion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231436</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231436</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Mon, 19 Feb 2007 18:34:54 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 18:42:58 GMT]]></title><description><![CDATA[<p>Kannste mir den Link geben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231445</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231445</guid><dc:creator><![CDATA[tsp]]></dc:creator><pubDate>Mon, 19 Feb 2007 18:42:58 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 18:44:09 GMT]]></title><description><![CDATA[<p><a href="http://infernal-beasts.drition.net/anderes/WinAPI.pdf" rel="nofollow">http://infernal-beasts.drition.net/anderes/WinAPI.pdf</a></p>
<p>Mfg Ominion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231447</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Mon, 19 Feb 2007 18:44:09 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 18:50:25 GMT]]></title><description><![CDATA[<p>Danke. <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/1231452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231452</guid><dc:creator><![CDATA[tsp]]></dc:creator><pubDate>Mon, 19 Feb 2007 18:50:25 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 18:59:01 GMT]]></title><description><![CDATA[<p>Und was ist, wenn CD-Laufwerke keinen Laufwerksbuchstaben haben, sondern in irgendein NTFS-Verzeichnis gemountet wurden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231459</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231459</guid><dc:creator><![CDATA[audacia]]></dc:creator><pubDate>Mon, 19 Feb 2007 18:59:01 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 19:02:32 GMT]]></title><description><![CDATA[<p>Na dann musst du dir was einfallen lassen <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>
<p>Mfg Ominion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231464</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231464</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Mon, 19 Feb 2007 19:02:32 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 19:11:01 GMT]]></title><description><![CDATA[<p>Das Tutorial ist recht gut, Ominion<br />
Und ich hab auch das mit den laufwerken gefunden.<br />
Aber das hilft mir irgendwie nicht. Haste noch ne andere Idee?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231471</guid><dc:creator><![CDATA[tsp]]></dc:creator><pubDate>Mon, 19 Feb 2007 19:11:01 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Mon, 19 Feb 2007 19:14:54 GMT]]></title><description><![CDATA[<p>leider nicht. ich habe dazu nur was für visual basic gefunden.</p>
<p>Mfg Ominion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1231474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231474</guid><dc:creator><![CDATA[Ominion]]></dc:creator><pubDate>Mon, 19 Feb 2007 19:14:54 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Tue, 20 Feb 2007 02:15:10 GMT]]></title><description><![CDATA[<p>tsp schrieb:</p>
<blockquote>
<p>Hey Ominion,</p>
<p>deine Fkt. klappt doch, war wohl mein Fehler.<br />
Aber ich wüsste gern mal, warum die ModifyDriveLock nict funzt. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /><br />
Ich habe es getestet: Die ModifyDriveLock gibt immer <strong>false</strong> zurück. Warum?</p>
</blockquote>
<p>Sry, hatte noch keine Zeit zu schreiben, hier liegt der Fehler:</p>
<pre><code>TCHAR szAddress[] = { TEXT('\\'), TEXT('\\'), TEXT('.'), TEXT('\\'), chDriveID, TEXT(':') };
</code></pre>
<p>Ein C-String muss immer mit einem \0 enden. Das habe ich hier übersehen, wegen der Zuweisung über die einzelnen Elemente.</p>
<p>Hier die korrigierte Fassung:</p>
<pre><code class="language-cpp">// Parameter: chDriveID &gt; Laufwerkbuchstaben, fLock &gt; true/false, lock/unlock
// Return-Wert: true &gt; Aufruf erfolgreich, false &gt; Aufruf fehlerhaft
bool ModifyDriveLock(TCHAR chDriveID, bool fLock)
{
    TCHAR szAddress[] = { TEXT('\\'), TEXT('\\'), TEXT('.'), TEXT('\\'), chDriveID, TEXT(':'), TEXT('\0') };
    HANDLE hDevice = CreateFile(szAddress, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, NULL, NULL);
    if(hDevice == INVALID_HANDLE_VALUE)
      return (false);

    DWORD dwBytesReturned = 0L;
    PREVENT_MEDIA_REMOVAL pmr = { fLock };

    bool fSuccess = static_cast&lt;bool&gt;(DeviceIoControl(hDevice, IOCTL_STORAGE_MEDIA_REMOVAL, &amp;pmr, sizeof(pmr), NULL, 0, &amp;dwBytesReturned, NULL));

    CloseHandle (hDevice);
    return (fSuccess);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1231608</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231608</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Tue, 20 Feb 2007 02:15:10 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Tue, 20 Feb 2007 09:11:19 GMT]]></title><description><![CDATA[<p>CodeFinder schrieb:</p>
<blockquote>
<p><a href="http://msdn2.microsoft.com/en-us/library/aa363216.aspx" rel="nofollow">DeviceIoControl</a></p>
</blockquote>
<p>Genau das meinte ich. <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/1231718</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1231718</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Tue, 20 Feb 2007 09:11:19 GMT</pubDate></item><item><title><![CDATA[Reply to CD-Laufwerk sperren on Tue, 20 Feb 2007 14:21:03 GMT]]></title><description><![CDATA[<blockquote>
<p>Ich krieg mein Laufwerk nicht mehr auf!! Helft mir!!!</p>
</blockquote>
<p>LOOL das kommt davon <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1232004</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1232004</guid><dc:creator><![CDATA[mikey]]></dc:creator><pubDate>Tue, 20 Feb 2007 14:21:03 GMT</pubDate></item></channel></rss>