<?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[Dateisperren unter Windows]]></title><description><![CDATA[<p>Wie kann ich Dateisperren unter Windows realisieren? Benutze häufiger den freien Borland-Compiler, deshalb wäre eine Beschreibung ohne MSVC nützlich oder auch ein Beschreibung, wie der MSVC-Mechanismus ohne VS benutzt werden kann. Auf fcntl.h bin ich bereits gestoßen, scheint Unix-spezifisch zu sein - oder kann es auch unter Windows verwendet werden? Kommentierter Beispiel-Code wäre dann schön.</p>
<p>Für Beispielcode, wie das mit MSVC realisiert wird, wäre ich auch dankbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/129806/dateisperren-unter-windows</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 17:11:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/129806.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Dec 2005 18:59:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dateisperren unter Windows on Fri, 16 Dec 2005 18:59:49 GMT]]></title><description><![CDATA[<p>Wie kann ich Dateisperren unter Windows realisieren? Benutze häufiger den freien Borland-Compiler, deshalb wäre eine Beschreibung ohne MSVC nützlich oder auch ein Beschreibung, wie der MSVC-Mechanismus ohne VS benutzt werden kann. Auf fcntl.h bin ich bereits gestoßen, scheint Unix-spezifisch zu sein - oder kann es auch unter Windows verwendet werden? Kommentierter Beispiel-Code wäre dann schön.</p>
<p>Für Beispielcode, wie das mit MSVC realisiert wird, wäre ich auch dankbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/943774</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/943774</guid><dc:creator><![CDATA[Aconcagua]]></dc:creator><pubDate>Fri, 16 Dec 2005 18:59:49 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Fri, 16 Dec 2005 19:21:39 GMT]]></title><description><![CDATA[<p>ACL evtl?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/943791</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/943791</guid><dc:creator><![CDATA[Asdfgh]]></dc:creator><pubDate>Fri, 16 Dec 2005 19:21:39 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Fri, 16 Dec 2005 19:27:04 GMT]]></title><description><![CDATA[<p>LockFile</p>
]]></description><link>https://www.c-plusplus.net/forum/post/943794</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/943794</guid><dc:creator><![CDATA[msdn]]></dc:creator><pubDate>Fri, 16 Dec 2005 19:27:04 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Sun, 18 Dec 2005 07:47:09 GMT]]></title><description><![CDATA[<p>Und warum kann ich damit noch auf die Datei zugreifen?</p>
<pre><code class="language-cpp">HANDLE hFile;

	hFile = CreateFile(
		&quot;c:\\test.txt&quot;,
		GENERIC_READ,
		FILE_SHARE_READ | FILE_SHARE_WRITE,
		NULL,
		OPEN_EXISTING,
		FILE_ATTRIBUTE_NORMAL,
		NULL);

	LockFile(hFile, 0, 0, 0xffffffff, 0xffffffff);
	MessageBox(&quot;Lock c:\\test.txt\n&quot;);

	Sleep(5000);

	UnlockFile(hFile, 0, 0, 0xffffffff, 0xffffffff);
	MessageBox(&quot;Unlock c:\\test.txt\n&quot;);

	CloseHandle(hFile);
</code></pre>
<p>Die Datei existiert, aber am Zugriff ändert sich nix.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/944647</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/944647</guid><dc:creator><![CDATA[hä?]]></dc:creator><pubDate>Sun, 18 Dec 2005 07:47:09 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Sun, 18 Dec 2005 07:59:44 GMT]]></title><description><![CDATA[<p>Wie meinst Du das? Das Locken bringt ja nur was, wenn Du von mehreren Threads/Processes gleichzeitig auf die Datei zugreifst...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/944656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/944656</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 18 Dec 2005 07:59:44 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Sun, 18 Dec 2005 08:01:50 GMT]]></title><description><![CDATA[<p>Ich hatte das so verstanden, dass die Datei nur noch durch mein<br />
Programm geöffnet werden kann und somit durch einfaches Anklicken<br />
im Explorer &quot;Zugriff verweigert&quot; o.ä. bringt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/944658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/944658</guid><dc:creator><![CDATA[hä?]]></dc:creator><pubDate>Sun, 18 Dec 2005 08:01:50 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Sun, 18 Dec 2005 08:09:04 GMT]]></title><description><![CDATA[<p>Das ist keine Datei-Sperre, sondern einfach ein &quot;kein-sharen&quot;...</p>
<pre><code class="language-cpp">HANDLE hFile;
  hFile = CreateFile(
        &quot;c:\\test.txt&quot;,
        GENERIC_READ,
        0,
        NULL,
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        NULL);

    MessageBox(&quot;Ungeshared c:\\test.txt\n&quot;);

    Sleep(5000);

    CloseHandle(hFile); 
    MessageBox(&quot;Jetzt wieder geshared c:\\test.txt\n&quot;);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/944661</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/944661</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 18 Dec 2005 08:09:04 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Sun, 18 Dec 2005 08:09:36 GMT]]></title><description><![CDATA[<p>Ich bekomme bei GetLastError immer NULL zurück.<br />
Also stimmt da doch was nicht?! Die Datei kann also<br />
nicht &quot;locked&quot; gesetzt werden. But why? :xmas2:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/944662</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/944662</guid><dc:creator><![CDATA[hä?]]></dc:creator><pubDate>Sun, 18 Dec 2005 08:09:36 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Sun, 18 Dec 2005 08:15:19 GMT]]></title><description><![CDATA[<p>Hä?<br />
Wo gibt es denn in den Code ein Fehler? Wo rufst Du GLE auf? Kannst Du mal *genau* sagen was Du machst und was Du machen willst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/944664</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/944664</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 18 Dec 2005 08:15:19 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Sun, 18 Dec 2005 08:25:16 GMT]]></title><description><![CDATA[<p>Ich möchte eine Datei vor dem Zugriff durch den Nutzer sperren.<br />
C:\test.txt soll nicht zugänglich sein.<br />
GLE rufe ich nach CloseHandle auf. Vielleicht ist ja LockFile gar nicht das<br />
was für meine Zwecke nötig wäre. <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>
]]></description><link>https://www.c-plusplus.net/forum/post/944667</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/944667</guid><dc:creator><![CDATA[hä?]]></dc:creator><pubDate>Sun, 18 Dec 2005 08:25:16 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Sun, 18 Dec 2005 22:42:54 GMT]]></title><description><![CDATA[<p>Also jetzt rein vom Planungstechnischen bräuchtest du denke ich ein Programm, welches ständig die Dateiaufrufe prüft.</p>
<p>Sprich es müsste eine Möglichkeit geben, genau das Öffnen einer Datei abzufangen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/945217</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/945217</guid><dc:creator><![CDATA[Mindphreaker]]></dc:creator><pubDate>Sun, 18 Dec 2005 22:42:54 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Mon, 19 Dec 2005 06:37:38 GMT]]></title><description><![CDATA[<p>&quot;Zugriff verweigert&quot; kenne ich auch von NTFS, setz doch einfach da die berechtigungen, dann haste doppelten schutz. (wenn das datei sperren funktioniert)</p>
<p>MSDN sagt:</p>
<blockquote>
<p>The Return Value section of the documentation for each function that sets the last-error code notes the conditions under which the function sets the last-error code. Most functions that set the thread's last-error code set it when they fail. However, some functions also set the last-error code when they succeed. If the function is not documented to set the last-error code, the value returned by this function is simply the most recent last-error code to have been set; some functions set the last-error code to 0 on success and others do not.</p>
</blockquote>
<p>also ist in dem fall kein fehler passiert, warum sollte das schliessen eines handles auch fehler geben, wenn es gültig ist <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>vielleicht bist du nur zu langsam um in den 5 sekunden auf die datei zuzugreifen <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 Mailmaster :xmas1:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/945253</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/945253</guid><dc:creator><![CDATA[Mailmaster]]></dc:creator><pubDate>Mon, 19 Dec 2005 06:37:38 GMT</pubDate></item><item><title><![CDATA[Reply to Dateisperren unter Windows on Thu, 22 Dec 2005 09:59:48 GMT]]></title><description><![CDATA[<p>Nein, er ist nicht zu langsam. Ich kann die Datei so auch net sperren!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/947631</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/947631</guid><dc:creator><![CDATA[ULan]]></dc:creator><pubDate>Thu, 22 Dec 2005 09:59:48 GMT</pubDate></item></channel></rss>