<?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[Ordner Überwachen]]></title><description><![CDATA[<p>Hi Ihr C/C++ Profis. Ich habe folgenden Problem. Ich muss für ein Schulprojekt<br />
ein tool schreiben der eine Ordner überwacht und wenn eine neue Datei rein kommt eine meldung macht (z.B per MessageBox)</p>
<p>Ihr würdet mir einen riesen gefall tun wenn mir jemanden ein lösungsforschlag machen könnten. Ich würde soger auch was bezahlen dafür. Bis 50 € würde ich dafür geben.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/77745/ordner-überwachen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 03:35:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/77745.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 Jun 2004 21:27:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ordner Überwachen on Wed, 23 Jun 2004 21:27:06 GMT]]></title><description><![CDATA[<p>Hi Ihr C/C++ Profis. Ich habe folgenden Problem. Ich muss für ein Schulprojekt<br />
ein tool schreiben der eine Ordner überwacht und wenn eine neue Datei rein kommt eine meldung macht (z.B per MessageBox)</p>
<p>Ihr würdet mir einen riesen gefall tun wenn mir jemanden ein lösungsforschlag machen könnten. Ich würde soger auch was bezahlen dafür. Bis 50 € würde ich dafür geben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/546790</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/546790</guid><dc:creator><![CDATA[Johan]]></dc:creator><pubDate>Wed, 23 Jun 2004 21:27:06 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Wed, 23 Jun 2004 21:34:32 GMT]]></title><description><![CDATA[<p>Johan schrieb:</p>
<blockquote>
<p>Hi Ihr C/C++ Profis. Ich habe folgenden Problem. Ich muss für ein Schulprojekt ein tool schreiben der eine Ordner überwacht und wenn eine neue Datei rein kommt eine meldung macht (z.B per MessageBox)</p>
<blockquote>
<p>da du messagebox sagst, geb ich dir meinen code, der winapi benutzt und verschiebe dann auch gleich den thtead nach mfc.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &lt;map&gt;
#include &lt;set&gt;
using namespace std;

char const* getExtension(char const* fileName){
	char const* result=fileName;
	for(char const* pos=fileName;*pos!='\0';++pos)
		if(*pos=='.')
			result=pos+1;
	return result;
}

map&lt;string,FILETIME&gt;* createSourceFileTimes(char const* path,set&lt;string&gt; const&amp; sourceExtensions){
	map&lt;string,FILETIME&gt;* fileTimes=new map&lt;string,FILETIME&gt;;
	WIN32_FIND_DATA fd;
	HANDLE hFF=FindFirstFile(&quot;*.*&quot;,&amp;fd);
	if(hFF!=INVALID_HANDLE_VALUE){
		do{
			if((fd.dwFileAttributes&amp;FILE_ATTRIBUTE_DIRECTORY)==0){
				if(strcmp(fd.cFileName,&quot;makefile&quot;)==0 || sourceExtensions.find(getExtension(fd.cFileName))!=sourceExtensions.end()){
					(*fileTimes)[fd.cFileName]=fd.ftLastWriteTime;
				}
			}
		}while(FindNextFile(hFF,&amp;fd));
		FindClose(hFF);
	}
	return fileTimes;
}

bool operator==(const FILETIME&amp; a,const FILETIME&amp; b){
	return a.dwLowDateTime==b.dwLowDateTime &amp;&amp; a.dwHighDateTime==b.dwHighDateTime;
}

int main(){
	set&lt;string&gt; sourceExtensions;
	sourceExtensions.insert(&quot;lang1&quot;);
	sourceExtensions.insert(&quot;lang1h&quot;);

	map&lt;string,FILETIME&gt; *oldTimes=createSourceFileTimes(&quot;.&quot;,sourceExtensions);
		
	HANDLE hFCN=FindFirstChangeNotification(&quot;.&quot;,FALSE,FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_LAST_WRITE);
	for(;;){
		WaitForSingleObject(hFCN,INFINITE);
		do{
			FindNextChangeNotification(hFCN);
		}while(WaitForSingleObject(hFCN,100)==WAIT_OBJECT_0);
		map&lt;string,FILETIME&gt; *newTimes=createSourceFileTimes(&quot;.&quot;,sourceExtensions);
		if(!equal(oldTimes-&gt;begin(),oldTimes-&gt;end(),newTimes-&gt;begin())){
			delete oldTimes;
			oldTimes=newTimes;
			system(&quot;make test&quot;);
			cout&lt;&lt;&quot;################################################################################&quot;&lt;&lt;endl;
		}
	}
}
</code></pre>
</blockquote>
<p>Ihr würdet mir einen riesen gefall tun wenn mir jemanden ein lösungsforschlag machen könnten. Ich würde soger auch was bezahlen dafür. Bis 50 € würde ich dafür geben.</p>
</blockquote>
<p>kauf die nächsten c++-bücher über links von diesem forum aus, dadurch kommt dann ne kleinigkeit rein, um marc++us von den serverkosten zu entlasten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/546797</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/546797</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Wed, 23 Jun 2004 21:34:32 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Wed, 23 Jun 2004 21:38:01 GMT]]></title><description><![CDATA[<p>Vielleicht hilft Dir <a href="http://www.student.lu.se/~nbi98oli/dnotify.html" rel="nofollow">dnotify</a> ja weiter...</p>
<p>edit: Funktioniert natürlich nur unter Linux...<br />
Volkard: Das ist übrigens das Ding von dem ich beim Forumstreffen irgendwann geredet habe falls Du Dich noch erinnerst. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/546800</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/546800</guid><dc:creator><![CDATA[nman]]></dc:creator><pubDate>Wed, 23 Jun 2004 21:38:01 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Wed, 23 Jun 2004 21:36:18 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=5" rel="nofollow">volkard</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=1" rel="nofollow">MFC mit dem Visual C++</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/546802</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/546802</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Wed, 23 Jun 2004 21:36:18 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Wed, 23 Jun 2004 22:57:18 GMT]]></title><description><![CDATA[<p>[quote=&quot;volkard&quot;][quote=&quot;Johan&quot;]Hi Ihr C/C++ Profis. Ich habe folgenden Problem. Ich muss für ein Schulprojekt ein tool schreiben der eine Ordner überwacht und wenn eine neue Datei rein kommt eine meldung macht (z.B per MessageBox)</p>
<blockquote>
<p>da du messagebox sagst, geb ich dir meinen code, der winapi benutzt und verschiebe dann auch gleich den thtead nach mfc.</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;windows.h&gt;
#include &lt;map&gt;
#include &lt;set&gt;
using namespace std;

char const* getExtension(char const* fileName){
	char const* result=fileName;
	for(char const* pos=fileName;*pos!='\0';++pos)
		if(*pos=='.')
			result=pos+1;
	return result;
}

map&lt;string,FILETIME&gt;* createSourceFileTimes(char const* path,set&lt;string&gt; const&amp; sourceExtensions){
	map&lt;string,FILETIME&gt;* fileTimes=new map&lt;string,FILETIME&gt;;
	WIN32_FIND_DATA fd;
	HANDLE hFF=FindFirstFile(&quot;*.*&quot;,&amp;fd);
	if(hFF!=INVALID_HANDLE_VALUE){
		do{
			if((fd.dwFileAttributes&amp;FILE_ATTRIBUTE_DIRECTORY)==0){
				if(strcmp(fd.cFileName,&quot;makefile&quot;)==0 || sourceExtensions.find(getExtension(fd.cFileName))!=sourceExtensions.end()){
					(*fileTimes)[fd.cFileName]=fd.ftLastWriteTime;
				}
			}
		}while(FindNextFile(hFF,&amp;fd));
		FindClose(hFF);
	}
	return fileTimes;
}

bool operator==(const FILETIME&amp; a,const FILETIME&amp; b){
	return a.dwLowDateTime==b.dwLowDateTime &amp;&amp; a.dwHighDateTime==b.dwHighDateTime;
}

int main(){
	set&lt;string&gt; sourceExtensions;
	sourceExtensions.insert(&quot;lang1&quot;);
	sourceExtensions.insert(&quot;lang1h&quot;);

	map&lt;string,FILETIME&gt; *oldTimes=createSourceFileTimes(&quot;.&quot;,sourceExtensions);
		
	HANDLE hFCN=FindFirstChangeNotification(&quot;.&quot;,FALSE,FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_LAST_WRITE);
	for(;;){
		WaitForSingleObject(hFCN,INFINITE);
		do{
			FindNextChangeNotification(hFCN);
		}while(WaitForSingleObject(hFCN,100)==WAIT_OBJECT_0);
		map&lt;string,FILETIME&gt; *newTimes=createSourceFileTimes(&quot;.&quot;,sourceExtensions);
		if(!equal(oldTimes-&gt;begin(),oldTimes-&gt;end(),newTimes-&gt;begin())){
			delete oldTimes;
			oldTimes=newTimes;
			system(&quot;make test&quot;);
			cout&lt;&lt;&quot;################################################################################&quot;&lt;&lt;endl;
		}
	}
}
</code></pre>
</blockquote>
<p>Kannst du vieleicht den quelcode ein wenig auskommentieren. es würde mir sehr weiter helfen<br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/546843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/546843</guid><dc:creator><![CDATA[Johan]]></dc:creator><pubDate>Wed, 23 Jun 2004 22:57:18 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Thu, 24 Jun 2004 05:08:25 GMT]]></title><description><![CDATA[<p>du könntest den code auch einfach zeile für zeile durchackern, dann lernste dabei noch was über das verstehen fremden codes^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/546867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/546867</guid><dc:creator><![CDATA[otze]]></dc:creator><pubDate>Thu, 24 Jun 2004 05:08:25 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Thu, 24 Jun 2004 06:58:11 GMT]]></title><description><![CDATA[<p>Johan schrieb:</p>
<blockquote>
<p>Kannst du vieleicht den quelcode ein wenig auskommentieren. es würde mir sehr weiter helfen</p>
</blockquote>
<p>nein, mag ich nicht.<br />
ich denke, mit dem code habe ich viel mehr gehelft, als notwendig.<br />
die anpassung, daß es statt &quot;system(&quot;make test&quot;);&quot; lieber &quot;MessageBox(NULL,&quot;sich hat was geaendert&quot;,&quot;aenderungswachter&quot;,MB_OK)&quot; macht und das lange if mit dem strcmp ersatzlos zu löschen, kannste selber schaffen. wenn nicht, biete nochmal 50Eu dafür an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/546902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/546902</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 24 Jun 2004 06:58:11 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Thu, 24 Jun 2004 19:57:27 GMT]]></title><description><![CDATA[<p>Eine frage noch kurz. wo wird der pfad des Ordners angegeben welche überwacht werden loss?<br />
Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/547465</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/547465</guid><dc:creator><![CDATA[Johan]]></dc:creator><pubDate>Thu, 24 Jun 2004 19:57:27 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Thu, 24 Jun 2004 20:05:22 GMT]]></title><description><![CDATA[<p>Hm, wenn es ein Schulprojekt ist, sollte<br />
evtl. der Lehrer den Code auch verstehen können <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="😃"
    /> <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>Devil</p>
]]></description><link>https://www.c-plusplus.net/forum/post/547474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/547474</guid><dc:creator><![CDATA[phlox81]]></dc:creator><pubDate>Thu, 24 Jun 2004 20:05:22 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Thu, 24 Jun 2004 21:17:21 GMT]]></title><description><![CDATA[<p>das ist ein schulprojekt aber den code müssen wir selber abliefern. was sol ich den lehrer den erzehlen wie ich den selber geschrieben wenn ich den code nicht selber verstehe. Es währe wirklich sehr hilfreich wenn mir jemanden den queltext ein wenig auskommentieren würde.<br />
thx.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/547510</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/547510</guid><dc:creator><![CDATA[Johan]]></dc:creator><pubDate>Thu, 24 Jun 2004 21:17:21 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Fri, 25 Jun 2004 04:56:14 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">HANDLE hFileChanged = FindFirstChangeNotification(&quot;c:\\mysql&quot;,TRUE,FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_SIZE);
HANDLE hWaitEvents[] = { hFileChanged};
DWORD dwResult = WaitForMultipleObjects(2, hWaitEvents,FALSE,INFINITE);
</code></pre>
<p>Das wichtigste.<br />
Watet bis sich im Ordner c:\mysql etwas tur und geht dann weiter.<br />
Ambesten in einem Thread einbauen da man sonst die GUI sperrt und auch noch herausfinden muss welches file es ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/547566</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/547566</guid><dc:creator><![CDATA[Unix-Tom]]></dc:creator><pubDate>Fri, 25 Jun 2004 04:56:14 GMT</pubDate></item><item><title><![CDATA[Reply to Ordner Überwachen on Fri, 25 Jun 2004 06:47:50 GMT]]></title><description><![CDATA[<p>die 2 in obigem code ist eine übungsaufgabe.<br />
lies immer brav die hilfe zu den funktionen und guck nach, ob die übergebenen parameter glaubwürdig sind. wenn nicht, korrigiere fehlerchen eigenständig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/547584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/547584</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 25 Jun 2004 06:47:50 GMT</pubDate></item></channel></rss>