<?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[ReadDirectoryChangesW funktioniert nicht im Debug Mode.]]></title><description><![CDATA[<p>Hey Peoplez,</p>
<p>also ich habe folgendes Problem. Ich nutze die WinAPI ReadDirectoryChangesW<br />
in der Releaseversion des Dienstes funktioniert die auch. Doch sobald ich den Dienst debuggen will funktioniert die Funktion nicht mehr und liefert mir Fehlercode 6. Was soviel bedeutet wie ERROR_INVALID_HANDLE nun woran liegt das ?</p>
<p>Folgender Code wird verwendet.</p>
<pre><code class="language-cpp">LPCTSTR arPrivelegeNames[]= {SE_BACKUP_NAME,SE_RESTORE_NAME,SE_CHANGE_NOTIFY_NAME};
for(int i = 0; i &lt; sizeof(arPrivelegeNames) / sizeof(arPrivelegeNames[0]); ++i)
{
 if( !EnablePrivilege(arPrivelegeNames[i], TRUE) )
 {
  TRACE(_T(&quot;Unable to enable privilege: %s    --  GetLastError(): %d\n&quot;),arPrivelegeNames[i], GetLastError());
  TRACE(_T(&quot;File: %s Line: %d\n&quot;), _T(__FILE__), __LINE__);
 }
}

m_hComPort = NULL;
DirInfo.hDir = CreateFile(m_strWatchPath,FILE_LIST_DIRECTORY,FILE_SHARE_READ  FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OVERLAPPED,NULL);

if (INVALID_HANDLE_VALUE == DirInfo.hDir)
{
 // Something is wrong ! The Directory doesn't exists
 char szMsg[256];
 sprintf(szMsg,&quot;Das angegebene Verzeichnis konnte nicht geöffnet werden !\nVerzeichnis: %s\nReturn Code: %d\n&quot;,m_strWatchPath,GetLastError());

 pLTdbi-&gt;AddToMessageLog(szMsg);
 // Thread will be closed !!
 // Now we have to stop the Service
 SetEvent(pTP-&gt;m_hStopEvent);
 return 0;
}

memset(lpOverlapped, 0, sizeof(lpOverlapped));
DirInfo.dwBufLength = sizeof(DirInfo.lpBuffer);
strcpy(DirInfo.lpszDirName,m_strWatchPath);
m_hComPort = CreateIoCompletionPort(DirInfo.hDir,m_hComPort,(DWORD)&amp;DirInfo,0);

if (0 == ReadDirectoryChangesW( DirInfo.hDir,DirInfo.lpBuffer,MAX_BUFFER,TRUE,FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_CREATION|FILE_NOTIFY_CHANGE_LAST_WRITE|FILE_NOTIFY_CHANGE_SIZE,&amp;DirInfo.dwBufLength,&amp;D irInfo.Overlapped,NULL))
{
 // Something is wrong
 DWORD   dwErr = GetLastError();
 printf(&quot;Error ReadDirectoryChangesW RC = %d\n&quot;,dwErr);
}
</code></pre>
<p>[ Dieser Beitrag wurde am 07.07.2003 um 10:36 Uhr von <strong>DaDaywalker</strong> editiert. ]</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/17542/readdirectorychangesw-funktioniert-nicht-im-debug-mode</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 06:32:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/17542.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 07 Jul 2003 08:30:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 08:30:00 GMT]]></title><description><![CDATA[<p>Hey Peoplez,</p>
<p>also ich habe folgendes Problem. Ich nutze die WinAPI ReadDirectoryChangesW<br />
in der Releaseversion des Dienstes funktioniert die auch. Doch sobald ich den Dienst debuggen will funktioniert die Funktion nicht mehr und liefert mir Fehlercode 6. Was soviel bedeutet wie ERROR_INVALID_HANDLE nun woran liegt das ?</p>
<p>Folgender Code wird verwendet.</p>
<pre><code class="language-cpp">LPCTSTR arPrivelegeNames[]= {SE_BACKUP_NAME,SE_RESTORE_NAME,SE_CHANGE_NOTIFY_NAME};
for(int i = 0; i &lt; sizeof(arPrivelegeNames) / sizeof(arPrivelegeNames[0]); ++i)
{
 if( !EnablePrivilege(arPrivelegeNames[i], TRUE) )
 {
  TRACE(_T(&quot;Unable to enable privilege: %s    --  GetLastError(): %d\n&quot;),arPrivelegeNames[i], GetLastError());
  TRACE(_T(&quot;File: %s Line: %d\n&quot;), _T(__FILE__), __LINE__);
 }
}

m_hComPort = NULL;
DirInfo.hDir = CreateFile(m_strWatchPath,FILE_LIST_DIRECTORY,FILE_SHARE_READ  FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OVERLAPPED,NULL);

if (INVALID_HANDLE_VALUE == DirInfo.hDir)
{
 // Something is wrong ! The Directory doesn't exists
 char szMsg[256];
 sprintf(szMsg,&quot;Das angegebene Verzeichnis konnte nicht geöffnet werden !\nVerzeichnis: %s\nReturn Code: %d\n&quot;,m_strWatchPath,GetLastError());

 pLTdbi-&gt;AddToMessageLog(szMsg);
 // Thread will be closed !!
 // Now we have to stop the Service
 SetEvent(pTP-&gt;m_hStopEvent);
 return 0;
}

memset(lpOverlapped, 0, sizeof(lpOverlapped));
DirInfo.dwBufLength = sizeof(DirInfo.lpBuffer);
strcpy(DirInfo.lpszDirName,m_strWatchPath);
m_hComPort = CreateIoCompletionPort(DirInfo.hDir,m_hComPort,(DWORD)&amp;DirInfo,0);

if (0 == ReadDirectoryChangesW( DirInfo.hDir,DirInfo.lpBuffer,MAX_BUFFER,TRUE,FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_CREATION|FILE_NOTIFY_CHANGE_LAST_WRITE|FILE_NOTIFY_CHANGE_SIZE,&amp;DirInfo.dwBufLength,&amp;D irInfo.Overlapped,NULL))
{
 // Something is wrong
 DWORD   dwErr = GetLastError();
 printf(&quot;Error ReadDirectoryChangesW RC = %d\n&quot;,dwErr);
}
</code></pre>
<p>[ Dieser Beitrag wurde am 07.07.2003 um 10:36 Uhr von <strong>DaDaywalker</strong> editiert. ]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/98230</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98230</guid><dc:creator><![CDATA[DaDaywalker]]></dc:creator><pubDate>Mon, 07 Jul 2003 08:30:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 08:46:00 GMT]]></title><description><![CDATA[<p>1.Ist das nun ein deutscher oder englischer Dienst?<br />
2.Was ist lpOverlapped?<br />
3.Bist du sicher, dass man CreateIoCompletionPort auf Directories anwenden kann? Ich hab da nur was von Dateien gelesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/98231</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98231</guid><dc:creator><![CDATA[RenéG]]></dc:creator><pubDate>Mon, 07 Jul 2003 08:46:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 08:50:00 GMT]]></title><description><![CDATA[<p>1. Nun was es für ein Dienst ist, ist doch egal oder nicht ? Ich meine<br />
ob Deutsch oder Englisch spielt derzeit keine Rolle.<br />
2. lpOverlapped... schau mal in der MSDN ....<br />
The OVERLAPPED structure contains information used in asynchronous input and output (I/O). Und nun rate mal was das LP bedeutet.<br />
3. Ja ich bin mir ziemlich sicher das das funktioniert. Um genau zu sein ich weiß es aber diese Fragen lösen mein Problem nicht !!!!!!!!!!!!!!</p>
<p>Also was Konstruktives wäre mir da schon recht danke euch !</p>
<p>MFG <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/98232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98232</guid><dc:creator><![CDATA[DaDaywalker]]></dc:creator><pubDate>Mon, 07 Jul 2003 08:50:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 09:35:00 GMT]]></title><description><![CDATA[<p>Zu 1.<br />
Es war nur eine informative Frage, da es sich echt komisch liest, mal deutsch, mal englisch!</p>
<p>Zu 2.<br />
Haha, in der MSDN gibts kein lpOverlapped, ich wollte von Dir nur wissen, wie DEIN lpOverlapped deklariert und initialisiert ist.</p>
<p>Zu 3.<br />
War eher informativ für mich, da mich interessiert, wie man über die serielle Schnittstelle dem Filesystem mitteilt, wann eine neue Datei anfängt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/98233</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98233</guid><dc:creator><![CDATA[RenéG]]></dc:creator><pubDate>Mon, 07 Jul 2003 09:35:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 09:44:00 GMT]]></title><description><![CDATA[<p>Serielle Schnittstelle na jetzt wirds interessant ?!?<br />
m_hComPort -&gt; heist Handle auf eine Completion Port !<br />
Und seid wann hat die Funktion CreatIOCompletionPort was mit Seriellen Schnittstellen zu tun.</p>
<p>Es wäre wirklich goldig das Problem zu lösen und nicht ständig erklären zu müssen wie was zu verstehen ist. Das können wir gern ein anderes mal klären.</p>
<p>Thema 2: Richtig ich weis das dies nicht in der MSDN steht deswegen habe ich gesagt OVERLAPPED ....<br />
und dich dann gefragt was das lp wohl bedeuten mag ???</p>
<p>so ist es in der winbase.h definiert also ist das so schwer ?</p>
<pre><code class="language-cpp">typedef struct _OVERLAPPED {
    DWORD   Internal;
    DWORD   InternalHigh;
    DWORD   Offset;
    DWORD   OffsetHigh;
    HANDLE  hEvent;
} OVERLAPPED, *LPOVERLAPPED;
</code></pre>
<p><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="😡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/98234</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98234</guid><dc:creator><![CDATA[DaDaywalker]]></dc:creator><pubDate>Mon, 07 Jul 2003 09:44:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 10:00:00 GMT]]></title><description><![CDATA[<p>Ach?<br />
Da bekommt man 'nen Codefetzen vorgeworfen, versucht, sich in dem Chaos zurechtzufinden, zu helfen und wird dann auch noch vollgepflaumt?</p>
<ol>
<li></li>
</ol>
<p>Zeile 9: m_hComPort = NULL;<br />
Ist echt Sch..., mitten im Code irgendwelche Handles auf NULL zu setzen. Sowas macht man normalerweise während der Initialisierung.<br />
2.<br />
Zeile 23: memset(lpOverlapped, 0, sizeof(lpOverlapped));</p>
<p>Und auf was zeigt jetzt lpOverlapped. Da Du uns diese wichtige Information ja unbedingt vorenthalten willst, nahm ich an, dass 'lpOverlapped = &amp;DirInfo.Overlapped' ist, womit nämlich geklärt wäre, dass in Deine Overlapped-Stuktur ein ungültiges Event-Handle existiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/98235</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98235</guid><dc:creator><![CDATA[RenéG]]></dc:creator><pubDate>Mon, 07 Jul 2003 10:00:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 10:03:00 GMT]]></title><description><![CDATA[<p>Du sagst:<br />
m_hComPort = CreateIoCompletionPort(DirInfo.hDir,m_hComPort,(DWORD)&amp;DirInfo,0);</p>
<p>aber in ReadDir.. usw. wird eine initiale Overlapped-Struktur übergeben.</p>
<p>Es müßte ausreichen das m_hComPort in die Overlapped-Struktur zu kopieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/98236</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98236</guid><dc:creator><![CDATA[Frank ll]]></dc:creator><pubDate>Mon, 07 Jul 2003 10:03:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 10:08:00 GMT]]></title><description><![CDATA[<p>Frank II ich probiere es mal aus Moment...</p>
<p>ReneG bitte fühl dich persönlich angegriffen.<br />
Ich meine ich versteh schon das du mir helfen willst aber in dem du hier sachen kritisierst wird das auch nichts...</p>
<p>aber trotzdem danke..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/98237</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98237</guid><dc:creator><![CDATA[DaDaywalker]]></dc:creator><pubDate>Mon, 07 Jul 2003 10:08:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 10:22:00 GMT]]></title><description><![CDATA[<blockquote>
<p>ReneG bitte fühl dich persönlich angegriffen.</p>
</blockquote>
<p>Tue ich auch, denn ich würde dir nicht solche komischen Sachen erzählen, innerhalb einer OVERLAPPED-Struktur, die einen Event erwartet, einen Completion-Port anzugeben!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/98238</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98238</guid><dc:creator><![CDATA[RenéG]]></dc:creator><pubDate>Mon, 07 Jul 2003 10:22:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 10:37:00 GMT]]></title><description><![CDATA[<p>es gibt im MSDN ein Beispiel:fwatch das macht genau das was du brauchst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/98239</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98239</guid><dc:creator><![CDATA[Frank ll]]></dc:creator><pubDate>Mon, 07 Jul 2003 10:37:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Mon, 07 Jul 2003 11:10:00 GMT]]></title><description><![CDATA[<p>Ok leutz bevor die gemühter hier Hochkochen...</p>
<p>ich habe es gefunden....<br />
nein es ist nicht die omminöse kopieraktion sondern einfach das<br />
memset auf die Struktur (die Initialisierung) denn diese muss auch für die DirInfo durchgeführt werden...</p>
<p>also leutz danke für die Hilfe......<br />
trotzdem.........</p>
<p>Nobody is perfect.... thanx for all</p>
]]></description><link>https://www.c-plusplus.net/forum/post/98240</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/98240</guid><dc:creator><![CDATA[DaDaywalker]]></dc:creator><pubDate>Mon, 07 Jul 2003 11:10:00 GMT</pubDate></item><item><title><![CDATA[Reply to ReadDirectoryChangesW funktioniert nicht im Debug Mode. on Tue, 18 Mar 2008 07:14:07 GMT]]></title><description><![CDATA[<p>Nice site!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1476287</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1476287</guid><dc:creator><![CDATA[Nikolet]]></dc:creator><pubDate>Tue, 18 Mar 2008 07:14:07 GMT</pubDate></item></channel></rss>